kempe-0.1.0.0: test/data/lex.kmp
; this is a comment
type Void {}
type Maybe a { Just a | Nothing }
type OS { Macos | Linux | Windows | Freebsd }
; just has type a -- Maybe a
; nothing has type -- Maybe a
isUnix : OS -- Bool
=: [
{ case
| Windows -> False
| _ -> True
}
]
osNum : OS -- Int
=: [
{ case
| Macos -> 1
| Linux -> 2
| Windows -> 3
| Freebsd -> 4
}
]
not : Bool -- Bool
=: [
{ case
| True -> False
| False -> True
}
]
rand : -- Int
=: $cfun"rand"
; all types are sized (monomorphized)
drop2 : a b --
=: [ drop drop ]
drop3 : a b c --
=: [ drop drop drop ]
trip : a -- a a a
=: [ dup dup ]
push3 : -- OS OS OS
=: [ Linux dup dup ]
aInt : a -- Int a
=: [ dip(3) ]
randTwice : -- Int Int
=: [ rand rand ]
odd : Int -- Bool
=: [ 2 % 0 = ]
%foreign kabi randTwice