Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
maybe [2014/08/23 20:12]
nikolaj
maybe [2014/09/15 20:17]
nikolaj
Line 4: Line 4:
 data  Maybe a  =  Nothing | Just a data  Maybe a  =  Nothing | Just a
   deriving (Eq, Ord)   deriving (Eq, Ord)
- 
-instance ​ Functor Maybe  where 
-    fmap _ Nothing ​      = Nothing 
-    fmap f (Just a)      = Just (f a) 
  
 instance ​ Monad Maybe  where instance ​ Monad Maybe  where
 +    return x  =  Just x
     (Just x) >>= k      = k x     (Just x) >>= k      = k x
     Nothing ​ >>= _      = Nothing     Nothing ​ >>= _      = Nothing
Line 18: Line 15:
     return ​             = Just     return ​             = Just
     fail _              = Nothing     fail _              = Nothing
 +    ​
 +-- instance ​ Functor Maybe  where
 +--  fmap _ Nothing ​      = Nothing
 +--  fmap f (Just a)      = Just (f a)
 </​code>​ </​code>​
  
Line 25: Line 26:
 ==== Parents ==== ==== Parents ====
 === Element of === === Element of ===
-[[Functor ​. Haskell]]+[[Monad . Haskell]]
Link to graph
Log In
Improvements of the human condition