Skip to content

Instantly share code, notes, and snippets.

@hdgarrood
Created March 4, 2015 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdgarrood/93b2d8b83d83a889d9b2 to your computer and use it in GitHub Desktop.
Save hdgarrood/93b2d8b83d83a889d9b2 to your computer and use it in GitHub Desktop.
module Coercible where
foreign import unsafeCoerce
"function unsafeCoerce(x) { return x }" :: forall a b. a -> b
class Coercible a b
coerce :: forall a b. (Coercible a b) => a -> b
coerce = unsafeCoerce
-- Coercible is an equivalence relation
instance reflexiveCoercible :: Coercible a a
instance symmetricCoercible :: (Coercible a b) => Coercible b a
instance transitiveCoercible :: (Coercible a b, Coercible b c) => Coercible a c
instance coercibleF :: (Coercible a b) => Coercible (f a) (f b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment