-
-
Save qnikst/3501333 to your computer and use it in GitHub Desktop.
Do magik
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
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