X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FGenerics.hs;fp=src%2FGenerics.hs;h=8e6658940fd0330cefe071e491c16bf13c6299d0;hb=d3a9a422741104a526dedfbe4032d81c728cdbe1;hp=0000000000000000000000000000000000000000;hpb=0c13a9f7630d82f8651371b31ee63b55b072ef8d;p=dead%2Fhtsn-import.git diff --git a/src/Generics.hs b/src/Generics.hs new file mode 100644 index 0000000..8e66589 --- /dev/null +++ b/src/Generics.hs @@ -0,0 +1,24 @@ +{-# 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