packages feed

alms-0.4.9: examples/ex07-poly.alms

(* Polymorphic version: An Interface Intervenes *)

let ap : all 'a 'b. ('a -> 'b) -> 'a -> 'b =
  fun 'a 'b ->
    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[int,int] g y)
    (fun z: int -> z + 1)

in print[int] (inc 5)