Created
February 28, 2012 18:32
-
-
Save bitonic/1934179 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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