pattern matching works? have to test more

This commit is contained in:
sebastianselander 2023-03-03 11:46:54 +01:00
parent 7656b46e3f
commit 03d7080396
5 changed files with 76 additions and 34 deletions

View file

@ -1,12 +1,30 @@
-- data Bool () where {
-- True : Bool ()
-- False : Bool ()
-- };
--
-- main : _Int ;
-- main = case True of {
-- False => 0 ;
-- True => 1
-- };
data List ('a) where {
Nil : List ('a)
Cons : 'a -> List ('a) -> List ('a)
Cons : ('a) -> List ('a) -> List ('a)
};
data Bool () where {
True : Bool ()
False : Bool ()
data Maybe ('a) where {
Nothing : Maybe ('a)
Just : 'a -> Maybe ('a)
};
main : List (_Int) ;
main = Cons 1 (Cons 0 Nil) ;
safeHead : List ('a) -> Maybe ('a) ;
safeHead xs =
case xs of {
Nil => Nothing ;
Cons x xs => Just x
};
main : Maybe (_Int) ;
main = safeHead (Cons 0 (Cons 1 Nil)) ;