Skip to content
Create a gist now

Instantly share code, notes, and snippets.

{-# LANGUAGE StandaloneDeriving, FlexibleContexts, UndecidableInstances #-}
-- Laungh ghci with -fobject-code to make the Fix/Tree trick work (thanks edwardk).
-- courtesy of hpc on #haskell
import Unsafe.Coerce
import Control.Monad.ST
toInteger :: Int -> Integer
isJust :: Maybe a -> Bool
null :: [a] -> Bool
id :: a -> a
toInteger = unsafeCoerce
isJust = unsafeCoerce
null = not . unsafeCoerce
id = unsafeCoerce
newtype Fix f = Fix (f (Fix f))
deriving instance (Show (Fix f), Show (f (Fix f))) => Show (Fix f)
data Tree a = Leaf a | Branch (Tree a) (Tree a)
deriving (Eq, Ord, Show, Read)
treeToLists :: Tree a -> Fix []
treeToLists = unsafeCoerce
unsafeSTToIO :: ST s a -> IO a
unsafeSTToIO = unsafeCoerce
undefined :: a
undefined = unsafeCoerce unsafeCoerce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.