Skip to content

Instantly share code, notes, and snippets.

@cheecheeo
Created July 29, 2014 00:30
Show Gist options
  • Save cheecheeo/10520eb63f0d41ac1903 to your computer and use it in GitHub Desktop.
Save cheecheeo/10520eb63f0d41ac1903 to your computer and use it in GitHub Desktop.
One line `deriving Show` for all types in the current file
{-# LANGUAGE TemplateHaskell #-}
import Data.DeriveTH
import Data.Derive.Show
import Language.Haskell.TH.Module.Magic
newtype Foo = Foo (Int, String)
data Bar a = Bar Int | Baz a (Bar a)
foo :: Foo -> Int -> String
foo (Foo (n, s)) x = if n == x then s else ""
$(concat `fmap` (mapM (deriveFromDec makeShow) =<< declarations) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment