-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoperad.idr
More file actions
27 lines (20 loc) · 702 Bytes
/
operad.idr
File metadata and controls
27 lines (20 loc) · 702 Bytes
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
module operad
-- We don't define the notion of operad, but we do make idris behave like one:
infixr 4 :-:
data Bulletin : (l : List Type) -> Type where
EmptyBulletin : Bulletin []
(:-:) : (x : a) -> (xs : Bulletin l) -> Bulletin (a :: l)
-- A multifunction
infixr 2 >>~>
(>>~>) : List Type -> Type -> Type
(>>~>) [] a = a
(>>~>) (x::xs) a = x -> xs >>~> a
-- multifunction application
infixr 0 >>$
(>>$) : (l >>~> a) -> Bulletin l -> a
(>>$) a EmptyBulletin = a
(>>$) f (x:-:xs) = f x >>$ xs
example : Bulletin [Int, Int, String]
example = 3 :-: 4 :-: "Hi" :-: EmptyBulletin
test : [Int, Int, String] >>~> Int
test a b s = a + b + (toIntNat $ Prelude.Strings.length s)