26 lines
No EOL
493 B
Text
26 lines
No EOL
493 B
Text
main = case f (Just 10) of {
|
|
Just a => a ;
|
|
Nothing => 0 ;
|
|
};
|
|
|
|
f x = bind (fmap (\s . s + 1) x) (\s . pure (s + 10)) ;
|
|
|
|
data Maybe () where {
|
|
Just : Int -> Maybe ()
|
|
Nothing : Maybe ()
|
|
};
|
|
|
|
fmap : (Int -> Int) -> Maybe () -> Maybe () ;
|
|
fmap f m = case m of {
|
|
Just a => pure (f a) ;
|
|
Nothing => Nothing ;
|
|
};
|
|
|
|
pure : Int -> Maybe () ;
|
|
pure x = Just x;
|
|
|
|
bind : Maybe () -> (Int -> Maybe ()) -> Maybe () ;
|
|
bind x f = case x of {
|
|
Just x => f x ;
|
|
Nothing => Nothing ;
|
|
}; |