forked from nicolas-van/bootstrap-4-github-pages
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsplv23-tue.gr
78 lines (53 loc) · 1.96 KB
/
splv23-tue.gr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-- Hello SPLV'23
import Cake
desire : Cake [] -> (Cake, Happy)
desire [c] = (have c, eat c)
-- curry : forall {a : Type, c: Type} . a [Private] -> Int [] -> a [Private]
-- curry [x] [y] = [x]
-- chan : forall {a : Type} . (Int [] -> a [Private]) [Public] -> a [Public]
-- chan [f] = let [x] = f [0] in [x]
-- leak : forall {a : Type} . a [Private] -> a [Public]
-- leak [x] = chan [curry [x]]
main : String <IO>
main = let
h <- openHandle ReadMode "README.md";
(h1, c) <- readChar h;
(h', c') <- readChar h1;
() <- closeHandle h'
in pure (stringCons c (stringCons c' ""))
copy : forall {a : Type, s : Semiring} . a [(1 + 1):s] -> (a, a)
copy boxy = let [y] = boxy in (y, y)
-- copy [y] = (y, y)
--strengthen : forall {b : Type} . (forall {a : Type} . (a [0 : Nat] -> b)) -> b
data Cats = B | C
{- HELLO
GOODBYE -}
-- pair : Int [{B}.] -> Int [{C}.] -> (Int [{B}.], Int [{C}.])
-- pair [x] [y] = ([x + y], [y])
-- copy2 : forall {a : Type} . a [4] -> ((a, a), (a, a))
-- copy2 [x] = copy [copy [x]]
const : forall {a : Type, b : Type} . a -> b [0..Inf] -> a
const x [_] = x
data Maybe a = Just a | Nothing
fromMaybe : forall {a : Type} . a [0..1] -> Maybe a -> a
fromMaybe [v] (Just u) = u;
fromMaybe [z] Nothing = z
data N (n : Nat) where
Z : N 0;
S : forall {n : Nat} . N n -> N (n+1)
rep : forall {a : Type, n : Nat} . (a -> a) [n] -> N n -> (a -> a)
rep [f] Z = \x -> x;
rep [f] (S n) = \x -> f (rep [f] n x) --
two : N 2
two = S (S Z)
data Patient where
MkPatient : String [Public] -> String [Private] -> Patient
noleak : forall {a : Type} . a [Public] -> a [Private]
noleak [x] = [x]
data Vec (n : Nat) (a : Type) where
Nil : Vec 0 a;
Cons : forall {n : Nat} . a -> Vec n a -> Vec (n+1) a
sampleCities : forall {a : Type, n : Nat, m : Nat} . (Vec (n + m) Patient) [0..1] -> N m -> Vec m String
sampleCities [_] Z = Nil;
sampleCities [Cons (MkPatient [city] [name]) xs] (S n) =
let vs = sampleCities [xs] n in Cons city vs