base-4.9.0.0: Basic libraries

Copyright(c) Universiteit Utrecht 2010-2011, University of Oxford 2012-2014
Licensesee libraries/base/LICENSE
Maintainerlibraries@haskell.org
Stabilityinternal
Portabilitynon-portable
Safe HaskellTrustworthy
LanguageHaskell2010

GHC.Generics

Contents

Description

If you're using GHC.Generics, you should consider using the http://hackage.haskell.org/package/generic-deriving package, which contains many useful generic functions.

Since: 4.6.0.0

Synopsis

Introduction

Datatype-generic functions are based on the idea of converting values of a datatype T into corresponding values of a (nearly) isomorphic type Rep T. The type Rep T is built from a limited set of type constructors, all provided by this module. A datatype-generic function is then an overloaded function with instances for most of these type constructors, together with a wrapper that performs the mapping between T and Rep T. By using this technique, we merely need a few generic instances in order to implement functionality that works for any representable type.

Representable types are collected in the Generic class, which defines the associated type Rep as well as conversion functions from and to. Typically, you will not define Generic instances by hand, but have the compiler derive them for you.

Representing datatypes

The key to defining your own datatype-generic functions is to understand how to represent datatypes using the given set of type constructors.

Let us look at an example first:

data Tree a = Leaf a | Node (Tree a) (Tree a)
  deriving Generic

The above declaration (which requires the language pragma DeriveGeneric) causes the following representation to be generated:

instance Generic (Tree a) where
  type Rep (Tree a) =
    D1 ('MetaData "Tree" "Main" "package-name" 'False)
      (C1 ('MetaCons "Leaf" 'PrefixI 'False)
         (S1 '(MetaSel 'Nothing
                          'NoSourceUnpackedness
                          'NoSourceStrictness
                          'DecidedLazy)
                (Rec0 a))
       :+:
       C1 ('MetaCons "Node" 'PrefixI 'False)
         (S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
               (Rec0 (Tree a))
          :*:
          S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
               (Rec0 (Tree a))))
  ...

Hint: You can obtain information about the code being generated from GHC by passing the -ddump-deriv flag. In GHCi, you can expand a type family such as Rep using the :kind! command.

This is a lot of information! However, most of it is actually merely meta-information that makes names of datatypes and constructors and more available on the type level.

Here is a reduced representation for Tree with nearly all meta-information removed, for now keeping only the most essential aspects:

instance Generic (Tree a) where
  type Rep (Tree a) =
    Rec0 a
    :+:
    (Rec0 (Tree a) :*: Rec0 (Tree a))

The Tree datatype has two constructors. The representation of individual constructors is combined using the binary type constructor :+:.

The first constructor consists of a single field, which is the parameter a. This is represented as Rec0 a.

The second constructor consists of two fields. Each is a recursive field of type Tree a, represented as Rec0 (Tree a). Representations of individual fields are combined using the binary type constructor :*:.

Now let us explain the additional tags being used in the complete representation:

  • The S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) tag indicates several things. The 'Nothing indicates that there is no record field selector associated with this field of the constructor (if there were, it would have been marked 'Just "recordName" instead). The other types contain meta-information on the field's strictness:
  • There is no {-# UNPACK #-} or {-# NOUNPACK #-} annotation in the source, so it is tagged with 'NoSourceUnpackedness.
  • There is no strictness (!) or laziness (~) annotation in the source, so it is tagged with 'NoSourceStrictness.
  • The compiler infers that the field is lazy, so it is tagged with 'DecidedLazy. Bear in mind that what the compiler decides may be quite different from what is written in the source. See DecidedStrictness for a more detailed explanation.

The 'MetaSel type is also an instance of the type class Selector, which can be used to obtain information about the field at the value level.

  • The C1 ('MetaCons "Leaf" 'PrefixI 'False) and C1 ('MetaCons "Node" 'PrefixI 'False) invocations indicate that the enclosed part is the representation of the first and second constructor of datatype Tree, respectively. Here, the meta-information regarding constructor names, fixity and whether it has named fields or not is encoded at the type level. The 'MetaCons type is also an instance of the type class Constructor. This type class can be used to obtain information about the constructor at the value level.
  • The D1 ('MetaData "Tree" "Main" "package-name" 'False) tag indicates that the enclosed part is the representation of the datatype Tree. Again, the meta-information is encoded at the type level. The 'MetaData type is an instance of class Datatype, which can be used to obtain the name of a datatype, the module it has been defined in, the package it is located under, and whether it has been defined using data or newtype at the value level.

Derived and fundamental representation types

There are many datatype-generic functions that do not distinguish between positions that are parameters or positions that are recursive calls. There are also many datatype-generic functions that do not care about the names of datatypes and constructors at all. To keep the number of cases to consider in generic functions in such a situation to a minimum, it turns out that many of the type constructors introduced above are actually synonyms, defining them to be variants of a smaller set of constructors.

Individual fields of constructors: K1

The type constructor Rec0 is a variant of K1:

type Rec0 = K1 R

Here, R is a type-level proxy that does not have any associated values.

There used to be another variant of K1 (namely Par0), but it has since been deprecated.

Meta information: M1

The type constructors S1, C1 and D1 are all variants of M1:

type S1 = M1 S
type C1 = M1 C
type D1 = M1 D

The types S, C and D are once again type-level proxies, just used to create several variants of M1.

Additional generic representation type constructors

Next to K1, M1, :+: and :*: there are a few more type constructors that occur in the representations of other datatypes.

Empty datatypes: V1

For empty datatypes, V1 is used as a representation. For example,

data Empty deriving Generic

yields

instance Generic Empty where
  type Rep Empty =
    D1 ('MetaData "Empty" "Main" "package-name" 'False) V1

Constructors without fields: U1

If a constructor has no arguments, then U1 is used as its representation. For example the representation of Bool is

instance Generic Bool where
  type Rep Bool =
    D1 ('MetaData "Bool" "Data.Bool" "package-name" 'False)
      (C1 ('MetaCons "False" 'PrefixI 'False) U1 :+: C1 ('MetaCons "True" 'PrefixI 'False) U1)

Representation of types with many constructors or many fields

As :+: and :*: are just binary operators, one might ask what happens if the datatype has more than two constructors, or a constructor with more than two fields. The answer is simple: the operators are used several times, to combine all the constructors and fields as needed. However, users /should not rely on a specific nesting strategy/ for :+: and :*: being used. The compiler is free to choose any nesting it prefers. (In practice, the current implementation tries to produce a more or less balanced nesting, so that the traversal of the structure of the datatype from the root to a particular component can be performed in logarithmic rather than linear time.)

Defining datatype-generic functions

A datatype-generic function comprises two parts:

  1. Generic instances for the function, implementing it for most of the representation type constructors introduced above.
  2. A wrapper that for any datatype that is in Generic, performs the conversion between the original value and its Rep-based representation and then invokes the generic instances.

As an example, let us look at a function encode that produces a naive, but lossless bit encoding of values of various datatypes. So we are aiming to define a function

encode :: Generic a => a -> [Bool]

where we use Bool as our datatype for bits.

For part 1, we define a class Encode'. Perhaps surprisingly, this class is parameterized over a type constructor f of kind * -> *. This is a technicality: all the representation type constructors operate with kind * -> * as base kind. But the type argument is never being used. This may be changed at some point in the future. The class has a single method, and we use the type we want our final function to have, but we replace the occurrences of the generic type argument a with f p (where the p is any argument; it will not be used).

class Encode' f where
  encode' :: f p -> [Bool]

With the goal in mind to make encode work on Tree and other datatypes, we now define instances for the representation type constructors V1, U1, :+:, :*:, K1, and M1.

Definition of the generic representation types

In order to be able to do this, we need to know the actual definitions of these types:

data    V1        p                       -- lifted version of Empty
data    U1        p = U1                  -- lifted version of ()
data    (:+:) f g p = L1 (f p) | R1 (g p) -- lifted version of Either
data    (:*:) f g p = (f p) :*: (g p)     -- lifted version of (,)
newtype K1    i c p = K1 { unK1 :: c }    -- a container for a c
newtype M1  i t f p = M1 { unM1 :: f p }  -- a wrapper

So, U1 is just the unit type, :+: is just a binary choice like Either, :*: is a binary pair like the pair constructor (,), and K1 is a value of a specific type c, and M1 wraps a value of the generic type argument, which in the lifted world is an f p (where we do not care about p).

Generic instances

The instance for V1 is slightly awkward (but also rarely used):

instance Encode' V1 where
  encode' x = undefined

There are no values of type V1 p to pass (except undefined), so this is actually impossible. One can ask why it is useful to define an instance for V1 at all in this case? Well, an empty type can be used as an argument to a non-empty type, and you might still want to encode the resulting type. As a somewhat contrived example, consider [Empty], which is not an empty type, but contains just the empty list. The V1 instance ensures that we can call the generic function on such types.

There is exactly one value of type U1, so encoding it requires no knowledge, and we can use zero bits:

instance Encode' U1 where
  encode' U1 = []

In the case for :+:, we produce False or True depending on whether the constructor of the value provided is located on the left or on the right:

instance (Encode' f, Encode' g) => Encode' (f :+: g) where
  encode' (L1 x) = False : encode' x
  encode' (R1 x) = True  : encode' x

In the case for :*:, we append the encodings of the two subcomponents:

instance (Encode' f, Encode' g) => Encode' (f :*: g) where
  encode' (x :*: y) = encode' x ++ encode' y

The case for K1 is rather interesting. Here, we call the final function encode that we yet have to define, recursively. We will use another type class Encode for that function:

instance (Encode c) => Encode' (K1 i c) where
  encode' (K1 x) = encode x

Note how Par0 and Rec0 both being mapped to K1 allows us to define a uniform instance here.

Similarly, we can define a uniform instance for M1, because we completely disregard all meta-information:

instance (Encode' f) => Encode' (M1 i t f) where
  encode' (M1 x) = encode' x

Unlike in K1, the instance for M1 refers to encode', not encode.

The wrapper and generic default

We now define class Encode for the actual encode function:

class Encode a where
  encode :: a -> [Bool]
  default encode :: (Generic a, Encode' (Rep a)) => a -> [Bool]
  encode x = encode' (from x)

The incoming x is converted using from, then we dispatch to the generic instances using encode'. We use this as a default definition for encode. We need the 'default encode' signature because ordinary Haskell default methods must not introduce additional class constraints, but our generic default does.

Defining a particular instance is now as simple as saying

instance (Encode a) => Encode (Tree a)

Omitting generic instances

It is not always required to provide instances for all the generic representation types, but omitting instances restricts the set of datatypes the functions will work for:

  • If no :+: instance is given, the function may still work for empty datatypes or datatypes that have a single constructor, but will fail on datatypes with more than one constructor.
  • If no :*: instance is given, the function may still work for datatypes where each constructor has just zero or one field, in particular for enumeration types.
  • If no K1 instance is given, the function may still work for enumeration types, where no constructor has any fields.
  • If no V1 instance is given, the function may still work for any datatype that is not empty.
  • If no U1 instance is given, the function may still work for any datatype where each constructor has at least one field.

An M1 instance is always required (but it can just ignore the meta-information, as is the case for encode above).

Generic constructor classes

Datatype-generic functions as defined above work for a large class of datatypes, including parameterized datatypes. (We have used Tree as our example above, which is of kind * -> *.) However, the Generic class ranges over types of kind *, and therefore, the resulting generic functions (such as encode) must be parameterized by a generic type argument of kind *.

What if we want to define generic classes that range over type constructors (such as Functor, Traversable, or Foldable)?

The Generic1 class

Like Generic, there is a class Generic1 that defines a representation Rep1 and conversion functions from1 and to1, only that Generic1 ranges over types of kind * -> *. The Generic1 class is also derivable.

The representation Rep1 is ever so slightly different from Rep. Let us look at Tree as an example again:

data Tree a = Leaf a | Node (Tree a) (Tree a)
  deriving Generic1

The above declaration causes the following representation to be generated:

instance Generic1 Tree where
  type Rep1 Tree =
    D1 ('MetaData "Tree" "Main" "package-name" 'False)
      (C1 ('MetaCons "Leaf" 'PrefixI 'False)
         (S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
               Par1)
       :+:
       C1 ('MetaCons "Node" 'PrefixI 'False)
         (S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
               (Rec1 Tree)
          :*:
          S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
               (Rec1 Tree)))
  ...
 

The representation reuses D1, C1, S1 (and thereby M1) as well as :+: and :*: from Rep. (This reusability is the reason that we carry around the dummy type argument for kind-*-types, but there are already enough different names involved without duplicating each of these.)

What's different is that we now use Par1 to refer to the parameter (and that parameter, which used to be a), is not mentioned explicitly by name anywhere; and we use Rec1 to refer to a recursive use of Tree a.

Representation of * -> * types

Unlike Rec0, the Par1 and Rec1 type constructors do not map to K1. They are defined directly, as follows:

newtype Par1   p = Par1 { unPar1 ::   p } -- gives access to parameter p
newtype Rec1 f p = Rec1 { unRec1 :: f p } -- a wrapper

In Par1, the parameter p is used for the first time, whereas Rec1 simply wraps an application of f to p.

Note that K1 (in the guise of Rec0) can still occur in a Rep1 representation, namely when the datatype has a field that does not mention the parameter.

The declaration

data WithInt a = WithInt Int a
  deriving Generic1

yields

class Rep1 WithInt where
  type Rep1 WithInt =
    D1 ('MetaData "WithInt" "Main" "package-name" 'False)
      (C1 ('MetaCons "WithInt" 'PrefixI 'False)
        (S1 ('MetaSel 'Nothing
                        'NoSourceUnpackedness
                        'NoSourceStrictness
                        'DecidedLazy)
              (Rec0 Int)
         :*:
         S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
              Par1))

If the parameter a appears underneath a composition of other type constructors, then the representation involves composition, too:

data Rose a = Fork a [Rose a]

yields

class Rep1 Rose where
  type Rep1 Rose =
    D1 ('MetaData "Rose" "Main" "package-name" 'False)
      (C1 ('MetaCons "Fork" 'PrefixI 'False)
        (S1 ('MetaSel 'Nothing
                        'NoSourceUnpackedness
                        'NoSourceStrictness
                        'DecidedLazy)
              Par1
         :*:
         S1 ('MetaSel 'Nothing
                         'NoSourceUnpackedness
                         'NoSourceStrictness
                         'DecidedLazy)
              ([] :.: Rec1 Rose)))

where

newtype (:.:) f g p = Comp1 { unComp1 :: f (g p) }

Representation of unlifted types

If one were to attempt to derive a Generic instance for a datatype with an unlifted argument (for example, Int#), one might expect the occurrence of the Int# argument to be marked with Rec0 Int#. This won't work, though, since Int# is of kind # and Rec0 expects a type of kind *. In fact, polymorphism over unlifted types is disallowed completely.

One solution would be to represent an occurrence of Int# with 'Rec0 Int' instead. With this approach, however, the programmer has no way of knowing whether the Int is actually an Int# in disguise.

Instead of reusing Rec0, a separate data family URec is used to mark occurrences of common unlifted types:

data family URec a p

data instance URec (Ptr ()) p = UAddr   { uAddr#   :: Addr#   }
data instance URec Char     p = UChar   { uChar#   :: Char#   }
data instance URec Double   p = UDouble { uDouble# :: Double# }
data instance URec Int      p = UFloat  { uFloat#  :: Float#  }
data instance URec Float    p = UInt    { uInt#    :: Int#    }
data instance URec Word     p = UWord   { uWord#   :: Word#   }

Several type synonyms are provided for convenience:

type UAddr   = URec (Ptr ())
type UChar   = URec Char
type UDouble = URec Double
type UFloat  = URec Float
type UInt    = URec Int
type UWord   = URec Word

The declaration

data IntHash = IntHash Int#
  deriving Generic

yields

instance Generic IntHash where
  type Rep IntHash =
    D1 ('MetaData "IntHash" "Main" "package-name" 'False)
      (C1 ('MetaCons "IntHash" 'PrefixI 'False)
        (S1 ('MetaSel 'Nothing
                        'NoSourceUnpackedness
                        'NoSourceStrictness
                        'DecidedLazy)
              UInt))

Currently, only the six unlifted types listed above are generated, but this may be extended to encompass more unlifted types in the future.

Generic representation types

data V1 p Source

Void: used for datatypes without constructors

data U1 p Source

Unit: used for constructors without arguments

Constructors

U1 

Instances

Eq (U1 p) 

Methods

(==) :: U1 p -> U1 p -> Bool Source

(/=) :: U1 p -> U1 p -> Bool Source

Ord (U1 p) 

Methods

compare :: U1 p -> U1 p -> Ordering Source

(<) :: U1 p -> U1 p -> Bool Source

(<=) :: U1 p -> U1 p -> Bool Source

(>) :: U1 p -> U1 p -> Bool Source

(>=) :: U1 p -> U1 p -> Bool Source

max :: U1 p -> U1 p -> U1 p Source

min :: U1 p -> U1 p -> U1 p Source

Read (U1 p) 
Show (U1 p) 

Methods

showsPrec :: Int -> U1 p -> ShowS Source

show :: U1 p -> String Source

showList :: [U1 p] -> ShowS Source

Generic (U1 p) 

Associated Types

type Rep (U1 p) :: * -> * Source

Methods

from :: U1 p -> Rep (U1 p) x Source

to :: Rep (U1 p) x -> U1 p Source

type Rep (U1 p) = D1 (MetaData "U1" "GHC.Generics" "base" False) (C1 (MetaCons "U1" PrefixI False) U1) 

newtype Par1 p Source

Used for marking occurrences of the parameter

Constructors

Par1 

Fields

Instances

Eq p => Eq (Par1 p) 

Methods

(==) :: Par1 p -> Par1 p -> Bool Source

(/=) :: Par1 p -> Par1 p -> Bool Source

Ord p => Ord (Par1 p) 

Methods

compare :: Par1 p -> Par1 p -> Ordering Source

(<) :: Par1 p -> Par1 p -> Bool Source

(<=) :: Par1 p -> Par1 p -> Bool Source

(>) :: Par1 p -> Par1 p -> Bool Source

(>=) :: Par1 p -> Par1 p -> Bool Source

max :: Par1 p -> Par1 p -> Par1 p Source

min :: Par1 p -> Par1 p -> Par1 p Source

Read p => Read (Par1 p) 
Show p => Show (Par1 p) 
Generic (Par1 p) 

Associated Types

type Rep (Par1 p) :: * -> * Source

Methods

from :: Par1 p -> Rep (Par1 p) x Source

to :: Rep (Par1 p) x -> Par1 p Source

type Rep (Par1 p) = D1 (MetaData "Par1" "GHC.Generics" "base" True) (C1 (MetaCons "Par1" PrefixI True) (S1 (MetaSel (Just Symbol "unPar1") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 p))) 

newtype Rec1 f p Source

Recursive calls of kind * -> *

Constructors

Rec1 

Fields

Instances

Eq (f p) => Eq (Rec1 f p) 

Methods

(==) :: Rec1 f p -> Rec1 f p -> Bool Source

(/=) :: Rec1 f p -> Rec1 f p -> Bool Source

Ord (f p) => Ord (Rec1 f p) 

Methods

compare :: Rec1 f p -> Rec1 f p -> Ordering Source

(<) :: Rec1 f p -> Rec1 f p -> Bool Source

(<=) :: Rec1 f p -> Rec1 f p -> Bool Source

(>) :: Rec1 f p -> Rec1 f p -> Bool Source

(>=) :: Rec1 f p -> Rec1 f p -> Bool Source

max :: Rec1 f p -> Rec1 f p -> Rec1 f p Source

min :: Rec1 f p -> Rec1 f p -> Rec1 f p Source

Read (f p) => Read (Rec1 f p) 
Show (f p) => Show (Rec1 f p) 

Methods

showsPrec :: Int -> Rec1 f p -> ShowS Source

show :: Rec1 f p -> String Source

showList :: [Rec1 f p] -> ShowS Source

Generic (Rec1 f p) 

Associated Types

type Rep (Rec1 f p) :: * -> * Source

Methods

from :: Rec1 f p -> Rep (Rec1 f p) x Source

to :: Rep (Rec1 f p) x -> Rec1 f p Source

type Rep (Rec1 f p) = D1 (MetaData "Rec1" "GHC.Generics" "base" True) (C1 (MetaCons "Rec1" PrefixI True) (S1 (MetaSel (Just Symbol "unRec1") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p)))) 

newtype K1 i c p Source

Constants, additional parameters and recursion of kind *

Constructors

K1 

Fields

Instances

Eq c => Eq (K1 i c p) 

Methods

(==) :: K1 i c p -> K1 i c p -> Bool Source

(/=) :: K1 i c p -> K1 i c p -> Bool Source

Ord c => Ord (K1 i c p) 

Methods

compare :: K1 i c p -> K1 i c p -> Ordering Source

(<) :: K1 i c p -> K1 i c p -> Bool Source

(<=) :: K1 i c p -> K1 i c p -> Bool Source

(>) :: K1 i c p -> K1 i c p -> Bool Source

(>=) :: K1 i c p -> K1 i c p -> Bool Source

max :: K1 i c p -> K1 i c p -> K1 i c p Source

min :: K1 i c p -> K1 i c p -> K1 i c p Source

Read c => Read (K1 i c p) 

Methods

readsPrec :: Int -> ReadS (K1 i c p) Source

readList :: ReadS [K1 i c p] Source

readPrec :: ReadPrec (K1 i c p) Source

readListPrec :: ReadPrec [K1 i c p] Source

Show c => Show (K1 i c p) 

Methods

showsPrec :: Int -> K1 i c p -> ShowS Source

show :: K1 i c p -> String Source

showList :: [K1 i c p] -> ShowS Source

Generic (K1 i c p) 

Associated Types

type Rep (K1 i c p) :: * -> * Source

Methods

from :: K1 i c p -> Rep (K1 i c p) x Source

to :: Rep (K1 i c p) x -> K1 i c p Source

type Rep (K1 i c p) = D1 (MetaData "K1" "GHC.Generics" "base" True) (C1 (MetaCons "K1" PrefixI True) (S1 (MetaSel (Just Symbol "unK1") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 c))) 

newtype M1 i c f p Source

Meta-information (constructor names, etc.)

Constructors

M1 

Fields

Instances

Eq (f p) => Eq (M1 i c f p) 

Methods

(==) :: M1 i c f p -> M1 i c f p -> Bool Source

(/=) :: M1 i c f p -> M1 i c f p -> Bool Source

Ord (f p) => Ord (M1 i c f p) 

Methods

compare :: M1 i c f p -> M1 i c f p -> Ordering Source

(<) :: M1 i c f p -> M1 i c f p -> Bool Source

(<=) :: M1 i c f p -> M1 i c f p -> Bool Source

(>) :: M1 i c f p -> M1 i c f p -> Bool Source

(>=) :: M1 i c f p -> M1 i c f p -> Bool Source

max :: M1 i c f p -> M1 i c f p -> M1 i c f p Source

min :: M1 i c f p -> M1 i c f p -> M1 i c f p Source

Read (f p) => Read (M1 i c f p) 

Methods

readsPrec :: Int -> ReadS (M1 i c f p) Source

readList :: ReadS [M1 i c f p] Source

readPrec :: ReadPrec (M1 i c f p) Source

readListPrec :: ReadPrec [M1 i c f p] Source

Show (f p) => Show (M1 i c f p) 

Methods

showsPrec :: Int -> M1 i c f p -> ShowS Source

show :: M1 i c f p -> String Source

showList :: [M1 i c f p] -> ShowS Source

Generic (M1 i c f p) 

Associated Types

type Rep (M1 i c f p) :: * -> * Source

Methods

from :: M1 i c f p -> Rep (M1 i c f p) x Source

to :: Rep (M1 i c f p) x -> M1 i c f p Source

type Rep (M1 i c f p) = D1 (MetaData "M1" "GHC.Generics" "base" True) (C1 (MetaCons "M1" PrefixI True) (S1 (MetaSel (Just Symbol "unM1") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p)))) 

data (f :+: g) p infixr 5 Source

Sums: encode choice between constructors

Constructors

L1 (f p) 
R1 (g p) 

Instances

(Eq (f p), Eq (g p)) => Eq ((:+:) f g p) 

Methods

(==) :: (f :+: g) p -> (f :+: g) p -> Bool Source

(/=) :: (f :+: g) p -> (f :+: g) p -> Bool Source

(Ord (f p), Ord (g p)) => Ord ((:+:) f g p) 

Methods

compare :: (f :+: g) p -> (f :+: g) p -> Ordering Source

(<) :: (f :+: g) p -> (f :+: g) p -> Bool Source

(<=) :: (f :+: g) p -> (f :+: g) p -> Bool Source

(>) :: (f :+: g) p -> (f :+: g) p -> Bool Source

(>=) :: (f :+: g) p -> (f :+: g) p -> Bool Source

max :: (f :+: g) p -> (f :+: g) p -> (f :+: g) p Source

min :: (f :+: g) p -> (f :+: g) p -> (f :+: g) p Source

(Read (f p), Read (g p)) => Read ((:+:) f g p) 

Methods

readsPrec :: Int -> ReadS ((f :+: g) p) Source

readList :: ReadS [(f :+: g) p] Source

readPrec :: ReadPrec ((f :+: g) p) Source

readListPrec :: ReadPrec [(f :+: g) p] Source

(Show (f p), Show (g p)) => Show ((:+:) f g p) 

Methods

showsPrec :: Int -> (f :+: g) p -> ShowS Source

show :: (f :+: g) p -> String Source

showList :: [(f :+: g) p] -> ShowS Source

Generic ((:+:) f g p) 

Associated Types

type Rep ((:+:) f g p) :: * -> * Source

Methods

from :: (f :+: g) p -> Rep ((f :+: g) p) x Source

to :: Rep ((f :+: g) p) x -> (f :+: g) p Source

type Rep ((:+:) f g p) = D1 (MetaData ":+:" "GHC.Generics" "base" False) ((:+:) (C1 (MetaCons "L1" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p)))) (C1 (MetaCons "R1" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g p))))) 

data (f :*: g) p infixr 6 Source

Products: encode multiple arguments to constructors

Constructors

(f p) :*: (g p) infixr 6 

Instances

(Eq (f p), Eq (g p)) => Eq ((:*:) f g p) 

Methods

(==) :: (f :*: g) p -> (f :*: g) p -> Bool Source

(/=) :: (f :*: g) p -> (f :*: g) p -> Bool Source

(Ord (f p), Ord (g p)) => Ord ((:*:) f g p) 

Methods

compare :: (f :*: g) p -> (f :*: g) p -> Ordering Source

(<) :: (f :*: g) p -> (f :*: g) p -> Bool Source

(<=) :: (f :*: g) p -> (f :*: g) p -> Bool Source

(>) :: (f :*: g) p -> (f :*: g) p -> Bool Source

(>=) :: (f :*: g) p -> (f :*: g) p -> Bool Source

max :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p Source

min :: (f :*: g) p -> (f :*: g) p -> (f :*: g) p Source

(Read (f p), Read (g p)) => Read ((:*:) f g p) 

Methods

readsPrec :: Int -> ReadS ((f :*: g) p) Source

readList :: ReadS [(f :*: g) p] Source

readPrec :: ReadPrec ((f :*: g) p) Source

readListPrec :: ReadPrec [(f :*: g) p] Source

(Show (f p), Show (g p)) => Show ((:*:) f g p) 

Methods

showsPrec :: Int -> (f :*: g) p -> ShowS Source

show :: (f :*: g) p -> String Source

showList :: [(f :*: g) p] -> ShowS Source

Generic ((:*:) f g p) 

Associated Types

type Rep ((:*:) f g p) :: * -> * Source

Methods

from :: (f :*: g) p -> Rep ((f :*: g) p) x Source

to :: Rep ((f :*: g) p) x -> (f :*: g) p Source

type Rep ((:*:) f g p) = D1 (MetaData ":*:" "GHC.Generics" "base" False) (C1 (MetaCons ":*:" (InfixI RightAssociative 6) False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f p))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g p))))) 

newtype (f :.: g) p infixr 7 Source

Composition of functors

Constructors

Comp1 

Fields

Instances

Eq (f (g p)) => Eq ((:.:) f g p) 

Methods

(==) :: (f :.: g) p -> (f :.: g) p -> Bool Source

(/=) :: (f :.: g) p -> (f :.: g) p -> Bool Source

Ord (f (g p)) => Ord ((:.:) f g p) 

Methods

compare :: (f :.: g) p -> (f :.: g) p -> Ordering Source

(<) :: (f :.: g) p -> (f :.: g) p -> Bool Source

(<=) :: (f :.: g) p -> (f :.: g) p -> Bool Source

(>) :: (f :.: g) p -> (f :.: g) p -> Bool Source

(>=) :: (f :.: g) p -> (f :.: g) p -> Bool Source

max :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p Source

min :: (f :.: g) p -> (f :.: g) p -> (f :.: g) p Source

Read (f (g p)) => Read ((:.:) f g p) 

Methods

readsPrec :: Int -> ReadS ((f :.: g) p) Source

readList :: ReadS [(f :.: g) p] Source

readPrec :: ReadPrec ((f :.: g) p) Source

readListPrec :: ReadPrec [(f :.: g) p] Source

Show (f (g p)) => Show ((:.:) f g p) 

Methods

showsPrec :: Int -> (f :.: g) p -> ShowS Source

show :: (f :.: g) p -> String Source

showList :: [(f :.: g) p] -> ShowS Source

Generic ((:.:) f g p) 

Associated Types

type Rep ((:.:) f g p) :: * -> * Source

Methods

from :: (f :.: g) p -> Rep ((f :.: g) p) x Source

to :: Rep ((f :.: g) p) x -> (f :.: g) p Source

type Rep ((:.:) f g p) = D1 (MetaData ":.:" "GHC.Generics" "base" True) (C1 (MetaCons "Comp1" PrefixI True) (S1 (MetaSel (Just Symbol "unComp1") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f (g p))))) 

Unboxed representation types

data family URec a p Source

Constants of kind #

Instances

Eq (URec Char p) 

Methods

(==) :: URec Char p -> URec Char p -> Bool Source

(/=) :: URec Char p -> URec Char p -> Bool Source

Eq (URec Double p) 
Eq (URec Float p) 

Methods

(==) :: URec Float p -> URec Float p -> Bool Source

(/=) :: URec Float p -> URec Float p -> Bool Source

Eq (URec Int p) 

Methods

(==) :: URec Int p -> URec Int p -> Bool Source

(/=) :: URec Int p -> URec Int p -> Bool Source

Eq (URec Word p) 

Methods

(==) :: URec Word p -> URec Word p -> Bool Source

(/=) :: URec Word p -> URec Word p -> Bool Source

Eq (URec (Ptr ()) p) 

Methods

(==) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source

(/=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source

Ord (URec Char p) 
Ord (URec Double p) 
Ord (URec Float p) 
Ord (URec Int p) 

Methods

compare :: URec Int p -> URec Int p -> Ordering Source

(<) :: URec Int p -> URec Int p -> Bool Source

(<=) :: URec Int p -> URec Int p -> Bool Source

(>) :: URec Int p -> URec Int p -> Bool Source

(>=) :: URec Int p -> URec Int p -> Bool Source

max :: URec Int p -> URec Int p -> URec Int p Source

min :: URec Int p -> URec Int p -> URec Int p Source

Ord (URec Word p) 
Ord (URec (Ptr ()) p) 

Methods

compare :: URec (Ptr ()) p -> URec (Ptr ()) p -> Ordering Source

(<) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source

(<=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source

(>) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source

(>=) :: URec (Ptr ()) p -> URec (Ptr ()) p -> Bool Source

max :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p Source

min :: URec (Ptr ()) p -> URec (Ptr ()) p -> URec (Ptr ()) p Source

Show (URec Char p) 
Show (URec Double p) 
Show (URec Float p) 
Show (URec Int p) 
Show (URec Word p) 
Generic (URec Char p) 

Associated Types

type Rep (URec Char p) :: * -> * Source

Methods

from :: URec Char p -> Rep (URec Char p) x Source

to :: Rep (URec Char p) x -> URec Char p Source

Generic (URec Double p) 

Associated Types

type Rep (URec Double p) :: * -> * Source

Methods

from :: URec Double p -> Rep (URec Double p) x Source

to :: Rep (URec Double p) x -> URec Double p Source

Generic (URec Float p) 

Associated Types

type Rep (URec Float p) :: * -> * Source

Methods

from :: URec Float p -> Rep (URec Float p) x Source

to :: Rep (URec Float p) x -> URec Float p Source

Generic (URec Int p) 

Associated Types

type Rep (URec Int p) :: * -> * Source

Methods

from :: URec Int p -> Rep (URec Int p) x Source

to :: Rep (URec Int p) x -> URec Int p Source

Generic (URec Word p) 

Associated Types

type Rep (URec Word p) :: * -> * Source

Methods

from :: URec Word p -> Rep (URec Word p) x Source

to :: Rep (URec Word p) x -> URec Word p Source

Generic (URec (Ptr ()) p) 

Associated Types

type Rep (URec (Ptr ()) p) :: * -> * Source

Methods

from :: URec (Ptr ()) p -> Rep (URec (Ptr ()) p) x Source

to :: Rep (URec (Ptr ()) p) x -> URec (Ptr ()) p Source

data URec Char = UChar {}

Used for marking occurrences of Char#

data URec Double = UDouble {}

Used for marking occurrences of Double#

data URec Float = UFloat {}

Used for marking occurrences of Float#

data URec Int = UInt {}

Used for marking occurrences of Int#

data URec Word = UWord {}

Used for marking occurrences of Word#

data URec (Ptr ()) = UAddr {}

Used for marking occurrences of Addr#

type Rep (URec Char p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UChar" PrefixI True) (S1 (MetaSel (Just Symbol "uChar#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UChar)) 
type Rep (URec Double p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UDouble" PrefixI True) (S1 (MetaSel (Just Symbol "uDouble#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UDouble)) 
type Rep (URec Float p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UFloat" PrefixI True) (S1 (MetaSel (Just Symbol "uFloat#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UFloat)) 
type Rep (URec Int p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UInt" PrefixI True) (S1 (MetaSel (Just Symbol "uInt#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UInt)) 
type Rep (URec Word p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UWord" PrefixI True) (S1 (MetaSel (Just Symbol "uWord#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UWord)) 
type Rep (URec (Ptr ()) p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UAddr" PrefixI True) (S1 (MetaSel (Just Symbol "uAddr#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UAddr)) 

type UAddr = URec (Ptr ()) Source

Type synonym for URec: Addr#

type UChar = URec Char Source

Type synonym for URec: Char#

type UDouble = URec Double Source

Type synonym for URec: Double#

type UFloat = URec Float Source

Type synonym for URec: Float#

type UInt = URec Int Source

Type synonym for URec: Int#

type UWord = URec Word Source

Type synonym for URec: Word#

Synonyms for convenience

type Rec0 = K1 R Source

Type synonym for encoding recursion (of kind *)

data R Source

Tag for K1: recursion (of kind *)

type D1 = M1 D Source

Type synonym for encoding meta-information for datatypes

type C1 = M1 C Source

Type synonym for encoding meta-information for constructors

type S1 = M1 S Source

Type synonym for encoding meta-information for record selectors

data D Source

Tag for M1: datatype

data C Source

Tag for M1: constructor

data S Source

Tag for M1: record selector

Meta-information

class Datatype d where Source

Class for datatypes that represent datatypes

Minimal complete definition

datatypeName, moduleName, packageName

Methods

datatypeName :: t d (f :: * -> *) a -> [Char] Source

The name of the datatype (unqualified)

moduleName :: t d (f :: * -> *) a -> [Char] Source

The fully-qualified name of the module where the type is declared

packageName :: t d (f :: * -> *) a -> [Char] Source

The package name of the module where the type is declared

isNewtype :: t d (f :: * -> *) a -> Bool Source

Marks if the datatype is actually a newtype

Instances

(KnownSymbol n, KnownSymbol m, KnownSymbol p, SingI Bool nt) => Datatype Meta (MetaData n m p nt) 

Methods

datatypeName :: t d f a -> [Char] Source

moduleName :: t d f a -> [Char] Source

packageName :: t d f a -> [Char] Source

isNewtype :: t d f a -> Bool Source

class Constructor c where Source

Class for datatypes that represent data constructors

Minimal complete definition

conName

Methods

conName :: t c (f :: * -> *) a -> [Char] Source

The name of the constructor

conFixity :: t c (f :: * -> *) a -> Fixity Source

The fixity of the constructor

conIsRecord :: t c (f :: * -> *) a -> Bool Source

Marks if this constructor is a record

Instances

(KnownSymbol n, SingI FixityI f, SingI Bool r) => Constructor Meta (MetaCons n f r) 

Methods

conName :: t c f a -> [Char] Source

conFixity :: t c f a -> Fixity Source

conIsRecord :: t c f a -> Bool Source

class Selector s where Source

Class for datatypes that represent records

Methods

selName :: t s (f :: * -> *) a -> [Char] Source

The name of the selector

selSourceUnpackedness :: t s (f :: * -> *) a -> SourceUnpackedness Source

The selector's unpackedness annotation (if any)

selSourceStrictness :: t s (f :: * -> *) a -> SourceStrictness Source

The selector's strictness annotation (if any)

selDecidedStrictness :: t s (f :: * -> *) a -> DecidedStrictness Source

The strictness that the compiler inferred for the selector

Instances

data Fixity Source

Datatype to represent the fixity of a constructor. An infix | declaration directly corresponds to an application of Infix.

Constructors

Prefix 
Infix Associativity Int 

data FixityI Source

This variant of Fixity appears at the type level.

data Associativity Source

Datatype to represent the associativity of a constructor

prec :: Fixity -> Int Source

Get the precedence of a fixity value.

data SourceUnpackedness Source

The unpackedness of a field as the user wrote it in the source code. For example, in the following data type:

data E = ExampleConstructor     Int
           {-# NOUNPACK #-} Int
           {-#   UNPACK #-} Int

The fields of ExampleConstructor have NoSourceUnpackedness, SourceNoUnpack, and SourceUnpack, respectively.

Instances

Eq SourceUnpackedness 
Ord SourceUnpackedness 
Read SourceUnpackedness 
Show SourceUnpackedness 
Generic SourceUnpackedness 
type Rep SourceUnpackedness = D1 (MetaData "SourceUnpackedness" "GHC.Generics" "base" False) ((:+:) (C1 (MetaCons "NoSourceUnpackedness" PrefixI False) U1) ((:+:) (C1 (MetaCons "SourceNoUnpack" PrefixI False) U1) (C1 (MetaCons "SourceUnpack" PrefixI False) U1))) 

data SourceStrictness Source

The strictness of a field as the user wrote it in the source code. For example, in the following data type:

data E = ExampleConstructor Int ~Int !Int

The fields of ExampleConstructor have NoSourceStrictness, SourceLazy, and SourceStrict, respectively.

data DecidedStrictness Source

The strictness that GHC infers for a field during compilation. Whereas there are nine different combinations of SourceUnpackedness and SourceStrictness, the strictness that GHC decides will ultimately be one of lazy, strict, or unpacked. What GHC decides is affected both by what the user writes in the source code and by GHC flags. As an example, consider this data type:

data E = ExampleConstructor {-# UNPACK #-} !Int !Int Int

Instances

data Meta Source

Datatype to represent metadata associated with a datatype (MetaData), constructor (MetaCons), or field selector (MetaSel).

  • In MetaData n m p nt, n is the datatype's name, m is the module in which the datatype is defined, p is the package in which the datatype is defined, and nt is 'True if the datatype is a newtype.
  • In MetaCons n f s, n is the constructor's name, f is its fixity, and s is 'True if the constructor contains record selectors.
  • In MetaSel mn su ss ds, if the field is uses record syntax, then mn is Just the record name. Otherwise, mn is 'Nothing. su and ss are the field's unpackedness and strictness annotations, and ds is the strictness that GHC infers for the field.

Instances

(KnownSymbol n, SingI FixityI f, SingI Bool r) => Constructor Meta (MetaCons n f r) 

Methods

conName :: t c f a -> [Char] Source

conFixity :: t c f a -> Fixity Source

conIsRecord :: t c f a -> Bool Source

(KnownSymbol n, KnownSymbol m, KnownSymbol p, SingI Bool nt) => Datatype Meta (MetaData n m p nt) 

Methods

datatypeName :: t d f a -> [Char] Source

moduleName :: t d f a -> [Char] Source

packageName :: t d f a -> [Char] Source

isNewtype :: t d f a -> Bool Source

(SingI (Maybe Symbol) mn, SingI SourceUnpackedness su, SingI SourceStrictness ss, SingI DecidedStrictness ds) => Selector Meta (MetaSel mn su ss ds) 

Generic type classes

class Generic a where Source

Representable types of kind *. This class is derivable in GHC with the DeriveGeneric flag on.

Minimal complete definition

from, to

Associated Types

type Rep a :: * -> * Source

Generic representation type

Methods

from :: a -> Rep a x Source

Convert from the datatype to its representation

to :: Rep a x -> a Source

Convert from the representation to the datatype

Instances

Generic Bool 

Associated Types

type Rep Bool :: * -> * Source

Methods

from :: Bool -> Rep Bool x Source

to :: Rep Bool x -> Bool Source

Generic Ordering 

Associated Types

type Rep Ordering :: * -> * Source

Generic () 

Associated Types

type Rep () :: * -> * Source

Methods

from :: () -> Rep () x Source

to :: Rep () x -> () Source

Generic DecidedStrictness 
Generic SourceStrictness 
Generic SourceUnpackedness 
Generic Associativity 
Generic Fixity 

Associated Types

type Rep Fixity :: * -> * Source

Generic Any 

Associated Types

type Rep Any :: * -> * Source

Methods

from :: Any -> Rep Any x Source

to :: Rep Any x -> Any Source

Generic All 

Associated Types

type Rep All :: * -> * Source

Methods

from :: All -> Rep All x Source

to :: Rep All x -> All Source

Generic ExitCode 

Associated Types

type Rep ExitCode :: * -> * Source

Generic Version 

Associated Types

type Rep Version :: * -> * Source

Generic Void 

Associated Types

type Rep Void :: * -> * Source

Methods

from :: Void -> Rep Void x Source

to :: Rep Void x -> Void Source

Generic [a] 

Associated Types

type Rep [a] :: * -> * Source

Methods

from :: [a] -> Rep [a] x Source

to :: Rep [a] x -> [a] Source

Generic (Maybe a) 

Associated Types

type Rep (Maybe a) :: * -> * Source

Methods

from :: Maybe a -> Rep (Maybe a) x Source

to :: Rep (Maybe a) x -> Maybe a Source

Generic (U1 p) 

Associated Types

type Rep (U1 p) :: * -> * Source

Methods

from :: U1 p -> Rep (U1 p) x Source

to :: Rep (U1 p) x -> U1 p Source

Generic (Par1 p) 

Associated Types

type Rep (Par1 p) :: * -> * Source

Methods

from :: Par1 p -> Rep (Par1 p) x Source

to :: Rep (Par1 p) x -> Par1 p Source

Generic (Last a) 

Associated Types

type Rep (Last a) :: * -> * Source

Methods

from :: Last a -> Rep (Last a) x Source

to :: Rep (Last a) x -> Last a Source

Generic (First a) 

Associated Types

type Rep (First a) :: * -> * Source

Methods

from :: First a -> Rep (First a) x Source

to :: Rep (First a) x -> First a Source

Generic (Product a) 

Associated Types

type Rep (Product a) :: * -> * Source

Methods

from :: Product a -> Rep (Product a) x Source

to :: Rep (Product a) x -> Product a Source

Generic (Sum a) 

Associated Types

type Rep (Sum a) :: * -> * Source

Methods

from :: Sum a -> Rep (Sum a) x Source

to :: Rep (Sum a) x -> Sum a Source

Generic (Endo a) 

Associated Types

type Rep (Endo a) :: * -> * Source

Methods

from :: Endo a -> Rep (Endo a) x Source

to :: Rep (Endo a) x -> Endo a Source

Generic (Dual a) 

Associated Types

type Rep (Dual a) :: * -> * Source

Methods

from :: Dual a -> Rep (Dual a) x Source

to :: Rep (Dual a) x -> Dual a Source

Generic (ZipList a) 

Associated Types

type Rep (ZipList a) :: * -> * Source

Methods

from :: ZipList a -> Rep (ZipList a) x Source

to :: Rep (ZipList a) x -> ZipList a Source

Generic (Complex a) 

Associated Types

type Rep (Complex a) :: * -> * Source

Methods

from :: Complex a -> Rep (Complex a) x Source

to :: Rep (Complex a) x -> Complex a Source

Generic (NonEmpty a) 

Associated Types

type Rep (NonEmpty a) :: * -> * Source

Methods

from :: NonEmpty a -> Rep (NonEmpty a) x Source

to :: Rep (NonEmpty a) x -> NonEmpty a Source

Generic (Option a) 

Associated Types

type Rep (Option a) :: * -> * Source

Methods

from :: Option a -> Rep (Option a) x Source

to :: Rep (Option a) x -> Option a Source

Generic (WrappedMonoid m) 

Associated Types

type Rep (WrappedMonoid m) :: * -> * Source

Generic (Last a) 

Associated Types

type Rep (Last a) :: * -> * Source

Methods

from :: Last a -> Rep (Last a) x Source

to :: Rep (Last a) x -> Last a Source

Generic (First a) 

Associated Types

type Rep (First a) :: * -> * Source

Methods

from :: First a -> Rep (First a) x Source

to :: Rep (First a) x -> First a Source

Generic (Max a) 

Associated Types

type Rep (Max a) :: * -> * Source

Methods

from :: Max a -> Rep (Max a) x Source

to :: Rep (Max a) x -> Max a Source

Generic (Min a) 

Associated Types

type Rep (Min a) :: * -> * Source

Methods

from :: Min a -> Rep (Min a) x Source

to :: Rep (Min a) x -> Min a Source

Generic (Identity a) 

Associated Types

type Rep (Identity a) :: * -> * Source

Methods

from :: Identity a -> Rep (Identity a) x Source

to :: Rep (Identity a) x -> Identity a Source

Generic (Either a b) 

Associated Types

type Rep (Either a b) :: * -> * Source

Methods

from :: Either a b -> Rep (Either a b) x Source

to :: Rep (Either a b) x -> Either a b Source

Generic (Rec1 f p) 

Associated Types

type Rep (Rec1 f p) :: * -> * Source

Methods

from :: Rec1 f p -> Rep (Rec1 f p) x Source

to :: Rep (Rec1 f p) x -> Rec1 f p Source

Generic (URec Char p) 

Associated Types

type Rep (URec Char p) :: * -> * Source

Methods

from :: URec Char p -> Rep (URec Char p) x Source

to :: Rep (URec Char p) x -> URec Char p Source

Generic (URec Double p) 

Associated Types

type Rep (URec Double p) :: * -> * Source

Methods

from :: URec Double p -> Rep (URec Double p) x Source

to :: Rep (URec Double p) x -> URec Double p Source

Generic (URec Float p) 

Associated Types

type Rep (URec Float p) :: * -> * Source

Methods

from :: URec Float p -> Rep (URec Float p) x Source

to :: Rep (URec Float p) x -> URec Float p Source

Generic (URec Int p) 

Associated Types

type Rep (URec Int p) :: * -> * Source

Methods

from :: URec Int p -> Rep (URec Int p) x Source

to :: Rep (URec Int p) x -> URec Int p Source

Generic (URec Word p) 

Associated Types

type Rep (URec Word p) :: * -> * Source

Methods

from :: URec Word p -> Rep (URec Word p) x Source

to :: Rep (URec Word p) x -> URec Word p Source

Generic (URec (Ptr ()) p) 

Associated Types

type Rep (URec (Ptr ()) p) :: * -> * Source

Methods

from :: URec (Ptr ()) p -> Rep (URec (Ptr ()) p) x Source

to :: Rep (URec (Ptr ()) p) x -> URec (Ptr ()) p Source

Generic (a, b) 

Associated Types

type Rep (a, b) :: * -> * Source

Methods

from :: (a, b) -> Rep (a, b) x Source

to :: Rep (a, b) x -> (a, b) Source

Generic (Proxy k t) 

Associated Types

type Rep (Proxy k t) :: * -> * Source

Methods

from :: Proxy k t -> Rep (Proxy k t) x Source

to :: Rep (Proxy k t) x -> Proxy k t Source

Generic (WrappedMonad m a) 

Associated Types

type Rep (WrappedMonad m a) :: * -> * Source

Methods

from :: WrappedMonad m a -> Rep (WrappedMonad m a) x Source

to :: Rep (WrappedMonad m a) x -> WrappedMonad m a Source

Generic (Arg a b) 

Associated Types

type Rep (Arg a b) :: * -> * Source

Methods

from :: Arg a b -> Rep (Arg a b) x Source

to :: Rep (Arg a b) x -> Arg a b Source

Generic (K1 i c p) 

Associated Types

type Rep (K1 i c p) :: * -> * Source

Methods

from :: K1 i c p -> Rep (K1 i c p) x Source

to :: Rep (K1 i c p) x -> K1 i c p Source

Generic ((:+:) f g p) 

Associated Types

type Rep ((:+:) f g p) :: * -> * Source

Methods

from :: (f :+: g) p -> Rep ((f :+: g) p) x Source

to :: Rep ((f :+: g) p) x -> (f :+: g) p Source

Generic ((:*:) f g p) 

Associated Types

type Rep ((:*:) f g p) :: * -> * Source

Methods

from :: (f :*: g) p -> Rep ((f :*: g) p) x Source

to :: Rep ((f :*: g) p) x -> (f :*: g) p Source

Generic ((:.:) f g p) 

Associated Types

type Rep ((:.:) f g p) :: * -> * Source

Methods

from :: (f :.: g) p -> Rep ((f :.: g) p) x Source

to :: Rep ((f :.: g) p) x -> (f :.: g) p Source

Generic (a, b, c) 

Associated Types

type Rep (a, b, c) :: * -> * Source

Methods

from :: (a, b, c) -> Rep (a, b, c) x Source

to :: Rep (a, b, c) x -> (a, b, c) Source

Generic (Alt k f a) 

Associated Types

type Rep (Alt k f a) :: * -> * Source

Methods

from :: Alt k f a -> Rep (Alt k f a) x Source

to :: Rep (Alt k f a) x -> Alt k f a Source

Generic (Const k a b) 

Associated Types

type Rep (Const k a b) :: * -> * Source

Methods

from :: Const k a b -> Rep (Const k a b) x Source

to :: Rep (Const k a b) x -> Const k a b Source

Generic (WrappedArrow a b c) 

Associated Types

type Rep (WrappedArrow a b c) :: * -> * Source

Methods

from :: WrappedArrow a b c -> Rep (WrappedArrow a b c) x Source

to :: Rep (WrappedArrow a b c) x -> WrappedArrow a b c Source

Generic (M1 i c f p) 

Associated Types

type Rep (M1 i c f p) :: * -> * Source

Methods

from :: M1 i c f p -> Rep (M1 i c f p) x Source

to :: Rep (M1 i c f p) x -> M1 i c f p Source

Generic (a, b, c, d) 

Associated Types

type Rep (a, b, c, d) :: * -> * Source

Methods

from :: (a, b, c, d) -> Rep (a, b, c, d) x Source

to :: Rep (a, b, c, d) x -> (a, b, c, d) Source

Generic (Product k f g a) 

Associated Types

type Rep (Product k f g a) :: * -> * Source

Methods

from :: Product k f g a -> Rep (Product k f g a) x Source

to :: Rep (Product k f g a) x -> Product k f g a Source

Generic (Sum k f g a) 

Associated Types

type Rep (Sum k f g a) :: * -> * Source

Methods

from :: Sum k f g a -> Rep (Sum k f g a) x Source

to :: Rep (Sum k f g a) x -> Sum k f g a Source

Generic (a, b, c, d, e) 

Associated Types

type Rep (a, b, c, d, e) :: * -> * Source

Methods

from :: (a, b, c, d, e) -> Rep (a, b, c, d, e) x Source

to :: Rep (a, b, c, d, e) x -> (a, b, c, d, e) Source

Generic (Compose k k1 f g a) 

Associated Types

type Rep (Compose k k1 f g a) :: * -> * Source

Methods

from :: Compose k k1 f g a -> Rep (Compose k k1 f g a) x Source

to :: Rep (Compose k k1 f g a) x -> Compose k k1 f g a Source

Generic (a, b, c, d, e, f) 

Associated Types

type Rep (a, b, c, d, e, f) :: * -> * Source

Methods

from :: (a, b, c, d, e, f) -> Rep (a, b, c, d, e, f) x Source

to :: Rep (a, b, c, d, e, f) x -> (a, b, c, d, e, f) Source

Generic (a, b, c, d, e, f, g) 

Associated Types

type Rep (a, b, c, d, e, f, g) :: * -> * Source

Methods

from :: (a, b, c, d, e, f, g) -> Rep (a, b, c, d, e, f, g) x Source

to :: Rep (a, b, c, d, e, f, g) x -> (a, b, c, d, e, f, g) Source

class Generic1 f where Source

Representable types of kind * -> *. This class is derivable in GHC with the DeriveGeneric flag on.

Minimal complete definition

from1, to1

Associated Types

type Rep1 f :: * -> * Source

Generic representation type

Methods

from1 :: f a -> Rep1 f a Source

Convert from the datatype to its representation

to1 :: Rep1 f a -> f a Source

Convert from the representation to the datatype

Instances

Generic1 [] 

Associated Types

type Rep1 ([] :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: [a] -> Rep1 [] a Source

to1 :: Rep1 [] a -> [a] Source

Generic1 Maybe 

Associated Types

type Rep1 (Maybe :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Maybe a -> Rep1 Maybe a Source

to1 :: Rep1 Maybe a -> Maybe a Source

Generic1 Last 

Associated Types

type Rep1 (Last :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Last a -> Rep1 Last a Source

to1 :: Rep1 Last a -> Last a Source

Generic1 First 

Associated Types

type Rep1 (First :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: First a -> Rep1 First a Source

to1 :: Rep1 First a -> First a Source

Generic1 Product 

Associated Types

type Rep1 (Product :: * -> TYPE Lifted) :: * -> * Source

Generic1 Sum 

Associated Types

type Rep1 (Sum :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Sum a -> Rep1 Sum a Source

to1 :: Rep1 Sum a -> Sum a Source

Generic1 Dual 

Associated Types

type Rep1 (Dual :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Dual a -> Rep1 Dual a Source

to1 :: Rep1 Dual a -> Dual a Source

Generic1 ZipList 

Associated Types

type Rep1 (ZipList :: * -> TYPE Lifted) :: * -> * Source

Generic1 Complex 

Associated Types

type Rep1 (Complex :: * -> TYPE Lifted) :: * -> * Source

Generic1 NonEmpty 

Associated Types

type Rep1 (NonEmpty :: * -> TYPE Lifted) :: * -> * Source

Generic1 Option 

Associated Types

type Rep1 (Option :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Option a -> Rep1 Option a Source

to1 :: Rep1 Option a -> Option a Source

Generic1 WrappedMonoid 

Associated Types

type Rep1 (WrappedMonoid :: * -> TYPE Lifted) :: * -> * Source

Generic1 Last 

Associated Types

type Rep1 (Last :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Last a -> Rep1 Last a Source

to1 :: Rep1 Last a -> Last a Source

Generic1 First 

Associated Types

type Rep1 (First :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: First a -> Rep1 First a Source

to1 :: Rep1 First a -> First a Source

Generic1 Max 

Associated Types

type Rep1 (Max :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Max a -> Rep1 Max a Source

to1 :: Rep1 Max a -> Max a Source

Generic1 Min 

Associated Types

type Rep1 (Min :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Min a -> Rep1 Min a Source

to1 :: Rep1 Min a -> Min a Source

Generic1 Identity 

Associated Types

type Rep1 (Identity :: * -> TYPE Lifted) :: * -> * Source

Generic1 (Either a) 

Associated Types

type Rep1 (Either a :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Either a a -> Rep1 (Either a) a Source

to1 :: Rep1 (Either a) a -> Either a a Source

Generic1 ((,) a) 

Associated Types

type Rep1 ((,) a :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: (a, a) -> Rep1 ((,) a) a Source

to1 :: Rep1 ((,) a) a -> (a, a) Source

Generic1 (Proxy *) 

Associated Types

type Rep1 (Proxy * :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Proxy * a -> Rep1 (Proxy *) a Source

to1 :: Rep1 (Proxy *) a -> Proxy * a Source

Generic1 (WrappedMonad m) 

Associated Types

type Rep1 (WrappedMonad m :: * -> TYPE Lifted) :: * -> * Source

Generic1 (Arg a) 

Associated Types

type Rep1 (Arg a :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Arg a a -> Rep1 (Arg a) a Source

to1 :: Rep1 (Arg a) a -> Arg a a Source

Generic1 ((,,) a b) 

Associated Types

type Rep1 ((,,) a b :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: (a, b, a) -> Rep1 ((,,) a b) a Source

to1 :: Rep1 ((,,) a b) a -> (a, b, a) Source

Generic1 (Alt (TYPE Lifted) f) 

Associated Types

type Rep1 (Alt (TYPE Lifted) f :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Alt (TYPE Lifted) f a -> Rep1 (Alt (TYPE Lifted) f) a Source

to1 :: Rep1 (Alt (TYPE Lifted) f) a -> Alt (TYPE Lifted) f a Source

Generic1 (Const (TYPE Lifted) a) 

Associated Types

type Rep1 (Const (TYPE Lifted) a :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Const (TYPE Lifted) a a -> Rep1 (Const (TYPE Lifted) a) a Source

to1 :: Rep1 (Const (TYPE Lifted) a) a -> Const (TYPE Lifted) a a Source

Generic1 (WrappedArrow a b) 

Associated Types

type Rep1 (WrappedArrow a b :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: WrappedArrow a b a -> Rep1 (WrappedArrow a b) a Source

to1 :: Rep1 (WrappedArrow a b) a -> WrappedArrow a b a Source

Generic1 ((,,,) a b c) 

Associated Types

type Rep1 ((,,,) a b c :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: (a, b, c, a) -> Rep1 ((,,,) a b c) a Source

to1 :: Rep1 ((,,,) a b c) a -> (a, b, c, a) Source

Generic1 (Product (TYPE Lifted) f g) 

Associated Types

type Rep1 (Product (TYPE Lifted) f g :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Product (TYPE Lifted) f g a -> Rep1 (Product (TYPE Lifted) f g) a Source

to1 :: Rep1 (Product (TYPE Lifted) f g) a -> Product (TYPE Lifted) f g a Source

Generic1 (Sum (TYPE Lifted) f g) 

Associated Types

type Rep1 (Sum (TYPE Lifted) f g :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Sum (TYPE Lifted) f g a -> Rep1 (Sum (TYPE Lifted) f g) a Source

to1 :: Rep1 (Sum (TYPE Lifted) f g) a -> Sum (TYPE Lifted) f g a Source

Generic1 ((,,,,) a b c d) 

Associated Types

type Rep1 ((,,,,) a b c d :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: (a, b, c, d, a) -> Rep1 ((,,,,) a b c d) a Source

to1 :: Rep1 ((,,,,) a b c d) a -> (a, b, c, d, a) Source

Functor f => Generic1 (Compose (TYPE Lifted) * f g) 

Associated Types

type Rep1 (Compose (TYPE Lifted) * f g :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: Compose (TYPE Lifted) * f g a -> Rep1 (Compose (TYPE Lifted) * f g) a Source

to1 :: Rep1 (Compose (TYPE Lifted) * f g) a -> Compose (TYPE Lifted) * f g a Source

Generic1 ((,,,,,) a b c d e) 

Associated Types

type Rep1 ((,,,,,) a b c d e :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: (a, b, c, d, e, a) -> Rep1 ((,,,,,) a b c d e) a Source

to1 :: Rep1 ((,,,,,) a b c d e) a -> (a, b, c, d, e, a) Source

Generic1 ((,,,,,,) a b c d e f) 

Associated Types

type Rep1 ((,,,,,,) a b c d e f :: * -> TYPE Lifted) :: * -> * Source

Methods

from1 :: (a, b, c, d, e, f, a) -> Rep1 ((,,,,,,) a b c d e f) a Source

to1 :: Rep1 ((,,,,,,) a b c d e f) a -> (a, b, c, d, e, f, a) Source