packages feed

kempe-0.1.0.0: test/data/ty.kmp

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

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 ]

trint : -- Int Int Int
      =: [ 0 trip ]

even : Int -- Bool
     =: [ 2 % 0 = ]

randBool : -- Bool
         =: [ rand even ]

maybeEven : -- (Maybe Int)
          =: [ rand dup even
                if( drop Nothing
                  , Just
                  )
             ]

push3 : -- OS OS OS
      =: [ Linux trip ]

doNothing : Int Int -- Int Int
          =: [ ]

%foreign cabi randBool
%foreign cabi maybeEven