Skip to content

Instantly share code, notes, and snippets.

@jonschoning
Created February 2, 2014 22:10
Show Gist options
  • Save jonschoning/8775663 to your computer and use it in GitHub Desktop.
Save jonschoning/8775663 to your computer and use it in GitHub Desktop.
-- http://stackoverflow.com/questions/7828072/how-does-haskell-printf-work
{-# LANGUAGE FlexibleInstances #-}
class FooType a where
bar :: IO () -> a
instance FooType (IO ()) where
bar = id
instance (Show x, FooType r) => FooType (x -> r) where
bar s x = bar (s >> print x)
foo :: FooType a => a
foo = bar (return ())
main :: IO ()
main = foo 3 "hello" True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment