Skip to content

Instantly share code, notes, and snippets.

@qnikst
Forked from Shimuuar/gist:3501111
Created August 28, 2012 17:47
Show Gist options
  • Save qnikst/3501333 to your computer and use it in GitHub Desktop.
Save qnikst/3501333 to your computer and use it in GitHub Desktop.
Do magik
import Data.Default
import Debug.Trace
class Magick a where
magickStorage :: [a] -> String
instance Magick Int where
magickStorage = const "Int"
instance Magick Char where
magickStorage = const "String"
instance Default Char where
def = '\0'
doMagick :: (Default a, Magick a) => [a]
doMagick = inner (undefined)
where inner :: (Default a, Magick a) => [a] -> [a]
inner s | trace (magickStorage s) True = [def]
{-
% runhaskell magick.hs
Int
[0]
String
"\NUL"
-}
main = do
let x = doMagick :: [Int]
y = doMagick :: String
print x
print y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment