Skip to content

Instantly share code, notes, and snippets.

@kokjo
Created September 6, 2014 17:52
Show Gist options
  • Save kokjo/fb7876b9e50511bd0c97 to your computer and use it in GitHub Desktop.
Save kokjo/fb7876b9e50511bd0c97 to your computer and use it in GitHub Desktop.
vardic
class VardicSum r where
sums :: Integer -> r
instance VardicSum Integer where
sums x = x
instance (Integral a, VardicSum b) => VardicSum (a -> b) where
sums x y = sums (x + toInteger y)
main = do
putStr . show $ (sums 5 5 5 5 :: Integer)
putStr "\n"
putStr . show $ (sums 5 5 5 :: Integer)
putStr "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment