All pastes #914115 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-02-22 17:07 UTC
rendered paste body
(*
  type packed_exception    = exists 'x.{contents : 'x}
*)
type unpacked_exception 'x = {content : 'x};
type exception_scope 't    = {bind_exception: !'x.unpacked_exception 'x -> 't };
type packed_exception      = {open_exception: !'t.exception_scope 't -> 't };

exception PolymorphicException of packed_exception;

value pack impl  = { open_exception = fun scope -> scope.bind_exception impl } ;

value exn_impl v = { content = v };

value test v     = raise (PolymorphicException (pack (exn_impl v)));