Safe Haskell | None |
---|---|
Language | Haskell2010 |
Provides Generic1
derivation of Representable
based on Field
.
This relies on the observation that a parametric function
forall a. f a -> a
is isomorphic to the set of "indices" of f
, i.e.
. With the appropriate instances, we can do anything with it that
we could with a hand-written ADT Rep
fRep
type. So, this module provides a way
to use exactly that type as Rep
, and the needed instances to make it
convenient to use.
Synopsis
- newtype Field f = Field {
- getField :: forall a. f a -> a
- newtype FieldRep f a = FieldRep (f a)
- class FieldPaths f where
- fieldPaths :: f [PathComponent]
- class GFieldPaths rec where
- gfieldPaths :: ([PathComponent] -> r) -> rec r
- class GTabulate rec where
Documentation
A Rep
type in the form of a parametric accessor function.
Instances
(Traversable f, Applicative f) => Eq (Field f) Source # | |
(Traversable f, Applicative f) => Ord (Field f) Source # | |
FieldPaths f => Show (Field f) Source # | |
(Traversable f, Applicative f) => Hashable (Field f) Source # | |
Defined in Data.Functor.Field | |
FieldPaths f => Portray (Field f) Source # | |
Defined in Data.Functor.Field | |
(Traversable f, Applicative f, FieldPaths f) => Diff (Field f) Source # | |
A newtype carrying instances for use with DerivingVia
.
This provides Applicative
, Monad
, Representable
, and
Update
.
FieldRep (f a) |
Instances
(Generic1 f, GTabulate (Rep1 f), Functor f) => Monad (FieldRep f) Source # | |
Functor f => Functor (FieldRep f) Source # | |
(Generic1 f, GTabulate (Rep1 f), Functor f) => Applicative (FieldRep f) Source # | |
Defined in Data.Functor.Field | |
(Generic1 f, GTabulate (Rep1 f), Functor f) => Distributive (FieldRep f) Source # | |
Defined in Data.Functor.Field | |
(Generic1 f, GTabulate (Rep1 f), Functor f) => Representable (FieldRep f) Source # | |
(Generic1 f, GTabulate (Rep1 f), GUpdate (Rep1 f), Functor f) => Update (FieldRep f) Source # | |
type Rep (FieldRep f) Source # | |
Defined in Data.Functor.Field |
class FieldPaths f where Source #
Build a record where each field has a description of the field's location.
This primarily powers the Show
and Portray
instances of Field
.
fieldPaths :: f [PathComponent] Source #
Instances
(Generic1 rec, GFieldPaths (Rep1 rec)) => FieldPaths (Wrapped1 (Generic1 :: (Type -> Type) -> Constraint) rec) Source # | |
Defined in Data.Functor.Field fieldPaths :: Wrapped1 Generic1 rec [PathComponent] Source # |
class GFieldPaths rec where Source #
The Generic1
implementation of FieldPaths
.
As with GTabulate
, derive this only to enable using your type as a
sub-record; otherwise just derive FieldPaths
directly.
gfieldPaths :: ([PathComponent] -> r) -> rec r Source #