]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blob - src/Generics.hs
8e6658940fd0330cefe071e491c16bf13c6299d0
[dead/htsn-import.git] / src / Generics.hs
1 {-# LANGUAGE DeriveGeneric #-}
2 {-# LANGUAGE NoMonomorphismRestriction #-}
3 {-# LANGUAGE TypeFamilies #-}
4
5 module Generics (
6 Generic(..),
7 to_tuple )
8 where
9
10 import Generics.SOP ( Code, Generic(..) )
11
12 -- | Convert a simple product type into a tuple, generically.
13 --
14 -- == __Examples__:
15 --
16 -- >>> import qualified GHC.Generics as GHC ( Generic )
17 -- >>> data Foo = Bar Int Int Int Int deriving (Show, GHC.Generic)
18 -- >>> instance Generic Foo
19 -- >>> let b = Bar 1 2 3 4
20 -- >>> to_tuple b :: (Int,Int,Int,Int)
21 -- (1,2,3,4)
22 --
23 to_tuple:: (Generic a, Generic c, Code a ~ Code c) => a -> c
24 to_tuple = to . from