packages feed

alms-0.6.0: examples/ex07-poly.alms

(* Polymorphic version: An Interface Intervenes *)

let ap : all 'c 'd. ('c -> 'd) -> 'c -> 'd =
  fun (f: 'a -> 'b) ->
    fun (x: 'a) ->
      f x

let iap = (ap :> all 'a 'b. ('a -o 'b) -> 'a -o 'b)

let inc : int -> int =
  fun (y: int) ->
    (fun (g: int -o int) ->
       iap g y)
    (fun (z: int) -> z + 1)

in print (inc 5)