Skip to content

Instantly share code, notes, and snippets.

@Shimuuar
Created August 28, 2012 17:25
Show Gist options
  • Save Shimuuar/3501111 to your computer and use it in GitHub Desktop.
Save Shimuuar/3501111 to your computer and use it in GitHub Desktop.
Do magik
class Magic a where
conjure :: String -> [a]
magikStorage :: [a] -> String
-- Use return type
doMagik :: Magic a => Int -> [a]
doMagik n = concat $ replicate n res
where
res = conjure $ magikStorage res -- Must be lazy in res !!!!
-- Pass dummy parameter
anotherMagic :: Magic a => Int -> [a]
anotherMagic n = concat $ replicate n $ go []
where
go :: Magic a => [a] -> [a]
go x = conjure $ magikStorage x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment