Add implicit foralls for bidir, update and unify pipeline
This commit is contained in:
parent
12bca1c32d
commit
9870802371
33 changed files with 1010 additions and 1055 deletions
|
|
@ -10,6 +10,10 @@ even : Int -> Bool ()
|
|||
even x = not (odd x)
|
||||
odd x = not (even x)
|
||||
|
||||
main = case even 64 of
|
||||
True => 1
|
||||
False => 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
data Bool () where {
|
||||
True : Bool ()
|
||||
data Bool () where
|
||||
True : Bool ()
|
||||
False : Bool ()
|
||||
};
|
||||
|
||||
toBool = case 0 of {
|
||||
0 => False;
|
||||
_ => True;
|
||||
};
|
||||
toBool x = case x of
|
||||
0 => False
|
||||
_ => True
|
||||
|
||||
fromBool b = case b of
|
||||
False => 0
|
||||
True => 1
|
||||
|
||||
main = fromBool (toBool 10)
|
||||
|
|
|
|||
10
sample-programs/basic-10.crf
Normal file
10
sample-programs/basic-10.crf
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
|
||||
|
||||
applyId : (forall a. a -> a) -> a -> a
|
||||
applyId f x = f x
|
||||
|
||||
id : a -> a
|
||||
id x = x
|
||||
|
||||
main = applyId id 4
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
data Bool () where {
|
||||
True : Bool ()
|
||||
data Bool () where
|
||||
True : Bool ()
|
||||
False : Bool ()
|
||||
};
|
||||
|
||||
main : Bool () -> a -> Int ;
|
||||
main b = case b of {
|
||||
False => (\x. 1);
|
||||
True => \x. 0;
|
||||
};
|
||||
main : Bool () -> a -> Int
|
||||
main b = case b of
|
||||
False => (\x. 1)
|
||||
True => (\x. 0)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
data Bool () where {
|
||||
True : Bool ()
|
||||
data Bool () where
|
||||
True : Bool ()
|
||||
False : Bool ()
|
||||
};
|
||||
|
||||
ifThenElse : forall a. Bool () -> a -> a -> a;
|
||||
ifThenElse b if else = case b of {
|
||||
True => if;
|
||||
False => else
|
||||
}
|
||||
ifThenElse : forall a. Bool () -> a -> a -> a
|
||||
ifThenElse b if else = case b of
|
||||
True => if
|
||||
False => else
|
||||
|
|
|
|||
|
|
@ -1,24 +1,20 @@
|
|||
data Maybe (a) where {
|
||||
data Maybe (a) where
|
||||
Nothing : Maybe (a)
|
||||
Just : a -> Maybe (a)
|
||||
};
|
||||
Just : a -> Maybe (a)
|
||||
|
||||
fromJust : Maybe (a) -> a ;
|
||||
fromJust : Maybe (a) -> a
|
||||
fromJust a =
|
||||
case a of {
|
||||
case a of
|
||||
Just a => a
|
||||
};
|
||||
|
||||
fromMaybe : a -> Maybe (a) -> a ;
|
||||
fromMaybe : a -> Maybe (a) -> a
|
||||
fromMaybe a b =
|
||||
case b of {
|
||||
Just a => a;
|
||||
case b of
|
||||
Just a => a
|
||||
Nothing => a
|
||||
};
|
||||
|
||||
maybe : b -> (a -> b) -> Maybe (a) -> b;
|
||||
maybe : b -> (a -> b) -> Maybe (a) -> b
|
||||
maybe b f ma =
|
||||
case ma of {
|
||||
Just a => f a;
|
||||
case ma of
|
||||
Just a => f a
|
||||
Nothing => b
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
data List (a) where {
|
||||
data List (a) where
|
||||
Nil : List (a)
|
||||
Cons : a -> List (a) -> List (a)
|
||||
};
|
||||
|
||||
test xs = case xs of {
|
||||
Cons Nil _ => 0 ;
|
||||
};
|
||||
|
||||
|
||||
test xs = case xs of
|
||||
Cons Nil _ => 0
|
||||
|
||||
List a /= List (List a)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue