{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE TypeFamilies #-} module Generics ( Generic(..), to_tuple ) where import Generics.SOP ( Code, Generic(..) ) -- | Convert a simple product type into a tuple, generically. -- -- == __Examples__: -- -- >>> import qualified GHC.Generics as GHC ( Generic ) -- >>> data Foo = Bar Int Int Int Int deriving (Show, GHC.Generic) -- >>> instance Generic Foo -- >>> let b = Bar 1 2 3 4 -- >>> to_tuple b :: (Int,Int,Int,Int) -- (1,2,3,4) -- to_tuple:: (Generic a, Generic c, Code a ~ Code c) => a -> c to_tuple = to . from