Haskell :Data structure for Optional Values

Java folks must appreciate ,that Haskell does not have Null type

For optional values it got elegant solution –

Maybe a = Just a
|Nothing
for example [Just 1,Just 2,Just 3,Nothing ] is a list of type Maybe Integer
and another being more helpful

Either a b = Right a
|Left b

Left might contain an error message and Right a correct value .

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s