Thu Feb 24 17:58:36 CET 2011
Whenever you see 'Just', keep in mind you're looking at a data
constructor. The same kind of constructor you could define yourself.
It's not a special keyword in the language, or anything like that.
The _type_ is Maybe, and its main purpose is to signal failure or
success (whatever that means).
On Tue, 2011-06-14 at 08:16 -0700, Michael Xavier wrote:
> I'm someone will offer a much more eloquent answer after me but here's
> my shot as a fellow beginner:
> The type Maybe is defined:
> data Maybe a = Just a | Nothing
> It means that a value of type Maybe String can manifest in 1 of 2
> values: either Nothing, which typically signifies an error has
> occurred or a "null" value that you'd see in other programming
> Just "foo" is a value that represent a value that is not nothing, such
> as a successful result from a computation. You can pattern match to
> get the value out of it:
> case somethingThatProducesAMaybe of
> Just success -> doStuff success
> Nothing -> error "Oh the humanity!"
> I hope that helps.
> Michael Xavier
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners