Hi, I'm a long time lurker trying to learn haskell. I'm trying to define (Maybe a) as an instance of Num. I wrote the following:instance (Num a) => Num (Maybe a) where (+) (Just a) (Just b) = Just (a + b) (-) (Just a) (Just b) = Just (a - b) (*) (Just a) (Just b) = Just (a * b) abs (Just a) = Just $ abs a negate (Just a) = Just (negate a) fromInteger = error "error" signum = error "error"
It works. However I can't add definitions for the case of Nothing. if i try to add(+) Nothing _ = Nothing
ghc gives me the error "Conflicting definitions for `+' ". Is there a standard solution to this problem? Thank you for reading.submitted by symbolic_haskell
[link] [32 comments]
I’ve just been trying to parse some text with Parsec and I ended up needing this tree to represent the result:
data Tree = Branch [Tree] | Leaf String deriving (Eq, Show)
The only kind of trees I’ve encountered before are Rose trees and Binary trees. What kind of tree is this? (Assuming it is a tree) It permits things to be nested many time without any useful data:
Branch [Branch [Branch ]]]
Which is actually what I needed.submitted by oligomous
[link] [4 comments]
Here's something I've been working on for the last couple of days: a buildbot add-on package for Haskell.
For those who don't know, buildbot is a Python eDSL for building continuous integration systems. This package adds cabal support, but other things will be added, too.
This is work in progress, so expect API breakage. Eventually I'll release this as a pypi package.
For now I just wanted to announce this so that others can try it out and send pull requests. (You'll notice that not all options and commands are implemented yet.) The easiest way to use it right now is to clone the repo and run pip install -e . inside it. Then buildbot restart master will automatically use the current version of the code in that directory.submitted by roche
[link] [2 comments]
On behalf of Haskell.org, we would like to thank all the generous donors we had in 2013!
Just in the last week of the year, we received about half of the total donations for the year. Nearly $900! That brings the total donations for the year to $1976! Thank you very much!
We are very grateful for all the donations we receive, financial and otherwise. As examples, GlobalSign graciously provides us with a free SSL certificate for use on hackage and each year community members collectively provide countless hours of time and energy towards making the Haskell community vibrant, positive, and relevant.
At the moment our primary expenses are hosting for haskell.org and hackage. The donations we have received will help ensure that we continue to have adequate hosting for the ever growing hackage!
Thank you and let's continue our momentum into 2014!
Sincerely, The Haskell.org Committeesubmitted by dagit
[link] [6 comments]
There are many things that are easier to write with GADTs than just ADTs, but some of them can still be written with ADTs -- it just takes more machinery. Are there good articles about how much new stuff can be expressed in the type system with just the addition of GADTs that could not be expressed in any way using ADTs?submitted by singpolyma
[link] [39 comments]