Of course you can use inline recursion like
fun Y f = f (fn x => Y fx)
or
fun Y fx = f (Y f) x
You can also use exceptions in the same way as a data type, but only monomorphically:
exception Roll of exn -> int -> int val unroll = fn Roll x => x fun Y f = (fn x => fn a => f (unroll xx) a) (Roll (fn x => fn a => f (unroll xx) a))
But I believe along with links to covers.
Edit: In fact, you can make this polymorphic using a local exception:
fun Y f : 'a -> 'b = let exception Roll of exn -> 'a -> 'b val unroll = fn Roll x => x in (fn x => fn a => f (unroll xx) a) (Roll (fn x => fn a => f (unroll xx) a)) end
source share