Almost got a lot of bugs fixed.

This commit is contained in:
Samuel Hammersberg 2023-03-26 22:21:44 +02:00
parent 9952eb0279
commit 91cfb21a35
4 changed files with 114 additions and 123 deletions

View file

@ -1,28 +1,27 @@
data Maybe () where {
Nothing : Maybe
Just : Int -> Maybe
Nothing : Maybe ()
Just : Int -> Maybe ()
};
fmap : (Int -> Int) -> Maybe -> Maybe ;
fmap f ma = case ma of {
Nothing => Nothing ;
Just a => Just (f a) ;
-- fmap : (Int -> Int) -> Maybe () -> Maybe () ;
-- fmap f ma = case ma of {
-- Nothing => Nothing ;
-- Just a => Just (f a) ;
-- };
main = case (Just 5) of {
Just a => a ;
Nothing => 1 ;
_ => 66 ;
};
pure : Int -> Maybe ;
pure x = Just x ;
ap mf ma = case mf of {
Just f => case ma of {
Nothing => Nothing;
Just a => Just (f a);
};
Nothing => Nothing;
};
return = pure;
bind ma f = case ma of {
Nothing => Nothing ;
Just a => f a ;
};
-- pure : Int -> Maybe () ;
-- pure x = Just x ;
--
-- return = pure;
--
-- bind : Maybe () -> (Int -> Maybe ()) -> Maybe () ;
-- bind ma f = case ma of {
-- Nothing => Nothing ;
-- Just a => f a ;
-- };