Safe Haskell | None |
---|---|
Language | Haskell2010 |
Anonymous records.
- data FD
- type (:::) s ty = ('(s, ty) :: (Symbol, *))
- type family InsertFD (s :: Symbol) (ty :: *) (fd :: FD) :: FD where ...
- type family NilFD :: FD where ...
- type family MkFD (ds :: [(Symbol, *)]) :: FD where ...
- type family PlusFD (fd1 :: FD) (fd2 :: FD) :: FD where ...
- type family DeleteFD (s :: Symbol) (fd :: FD) :: FD where ...
- type family LookupFD (s :: Symbol) (fd :: FD) :: * where ...
- type family LMergeFD (fd1 :: FD) (fd2 :: FD) :: FD where ...
- type family HomogenizeFD (c :: *) (fd :: FD) :: FD where ...
- type family FDAbsent (s :: Symbol) (fd :: FD) :: Constraint where ...
- type family FDFoldable (fun :: *) (fd1 :: FD) (fd2 :: FD) (m :: *) where ...
- type family FDFoldable2 (fun :: *) (fd1 :: FD) (fd2 :: FD) (fd3 :: FD) (m :: *) where ...
- type family FDHomogenous (a :: *) (fd :: FD) :: Constraint where ...
- type family FDPure (a :: *) (fd :: FD) :: Constraint where ...
- type family FDSplat (fd1 :: FD) (fd2 :: FD) (fd3 :: FD) :: Constraint where ...
- type family FDSplatA (i :: * -> *) (fd1 :: FD) (fd2 :: FD) (fd3 :: FD) :: Constraint where ...
- fdIdentities :: forall s fd a. '(LookupFD s (InsertFD s a fd), InsertFD s (LookupFD s fd) fd, DeleteFD s (DeleteFD s fd), InsertFD s a (DeleteFD s fd), Lookup1 s (FieldsFD (DeleteFD s fd)), MkFD (FirstHalf (FieldsFD fd)) `PlusFD` MkFD (SecondHalf (FieldsFD fd))) :~: '(a, fd, DeleteFD s fd, InsertFD s a fd, Nothing, fd)
- data R fd
- type Rcrd ds = R (MkFD ds)
- nilR :: R NilFD
- oneR :: KnownSymbol s => Label s -> a -> R (InsertFD s a NilFD)
- plusR :: R fd1 -> R fd2 -> R (PlusFD fd1 fd2)
- addR :: (KnownSymbol s, FDAbsent s fd) => Label s -> a -> R fd -> R (InsertFD s a fd)
- adjustR :: (KnownSymbol s, fd1 ~ InsertFD s a fd2, fd2 ~ InsertFD s b fd1) => Label s -> (a -> b) -> R fd1 -> R fd2
- deleteR :: KnownSymbol s => Label s -> R fd -> R (DeleteFD s fd)
- extricate1R :: KnownSymbol s => Label s -> R fd -> Eval (LookupFD s fd)
- getR :: KnownSymbol s => Label s -> R fd -> LookupFD s fd
- insertR :: KnownSymbol s => Label s -> a -> R fd -> R (InsertFD s a fd)
- lensR :: (KnownSymbol s, fd1 ~ InsertFD s a fd2, fd2 ~ InsertFD s b fd1, Functor f) => Label s -> (a -> f b) -> R fd1 -> f (R fd2)
- lmergeR :: R fd1 -> R fd2 -> R (LMergeFD fd1 fd2)
- setR :: forall s fd. KnownSymbol s => Label s -> LookupFD s fd -> R fd -> R fd
- class FPure a s b where
- data RCompare = MkRCompare
- data REq = MkREq
- data RShowField = MkRShowField
- rfoldR :: (Monoid m, FDHomogenous m fd) => R fd -> m
- rfoldMapR :: forall fd1 fd2 fun m. FDFoldable fun fd1 fd2 m => fun -> R fd2 -> m
- rfoldMap2R :: forall fd1 fd2 fd3 fun m. FDFoldable2 fun fd1 fd2 fd3 m => fun -> R fd2 -> R fd2 -> m
- rlabelR :: FDPure RLabel fd => R fd
- rmapR :: forall fd1 fd2 fd3 fun. (FDPure fun fd1, FDSplat fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => fun -> R fd2 -> R fd3
- rmapAR :: forall fun fd1 fd2 fd3 i. (Applicative i, FDPure fun fd1, FDSplatA i fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => fun -> R fd2 -> i (R fd3)
- rmappendR :: FDPure RMAppendR fd => R fd
- rmemptyR :: FDPure RMEmpty fd => R fd
- rpureR :: FDPure a fd => a -> R fd
- rpolypureR :: FDPure a fd => a -> R fd
- rsappendR :: FDPure RSAppendR fd => R fd
- rsplatR :: (FDSplat fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => R fd1 -> R fd2 -> R fd3
- rsplatAR :: (Applicative i, FDSplatA i fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => R fd1 -> R fd2 -> i (R fd3)
- monoadjustR :: forall s fd. KnownSymbol s => Label s -> (LookupFD s fd -> LookupFD s fd) -> R fd -> R fd
- lens'R :: forall s fd f. (KnownSymbol s, Functor f) => Label s -> (LookupFD s fd -> f (LookupFD s fd)) -> R fd -> f (R fd)
- rmonopureR :: FDPure (RMonoPure a) fd => a -> R fd
- data Label s
- mkLabel :: forall s. Label s
Data kind for fields declarations
An abstract data kind for the field declarations that determine an anonymous record type. The user can only build this type using the handful of type families exported by this module.
These families ensure that GHC's type equality relation ~
ignores
the order in which fields with different names are added to/removed
from the declarations.
Constructors
type family InsertFD (s :: Symbol) (ty :: *) (fd :: FD) :: FD where ... Source #
InsertFD s ty (MkFD ds) = MkFD (Insert1 s ty ds) |
type family MkFD (ds :: [(Symbol, *)]) :: FD where ... Source #
type family PlusFD (fd1 :: FD) (fd2 :: FD) :: FD where ... Source #
Each field that is in both declaration lists will have an undefined type.
*Data.Ruin.R> :toneR
#x () `plusR
` (oneR
#x () `plusR
`oneR
#y ())oneR
#x () `plusR
` (oneR
#x () `plusR
`oneR
#y ()) ::R
('MkFD '[ '("x", (TypeError
...)), '("y", ())) ])
PlusFD (MkFD ds1) (MkFD ds2) = MkFD (Plus1 (MkFD ds1) (MkFD ds2) ds1 ds2) |
Operations
type family DeleteFD (s :: Symbol) (fd :: FD) :: FD where ... Source #
DeleteFD s (MkFD ds) = MkFD (Delete1 s ds) |
type family LookupFD (s :: Symbol) (fd :: FD) :: * where ... Source #
LookupFD s (MkFD ds) = FinalLookup s (MkFD ds) (Lookup1 s ds) |
type family LMergeFD (fd1 :: FD) (fd2 :: FD) :: FD where ... Source #
A left-biased version of PlusFD
; instead of undefined types,
shared fields will keep their type from the left declarations.
LMergeFD (MkFD ds1) (MkFD ds2) = MkFD (LMerge1 ds1 ds2) |
type family HomogenizeFD (c :: *) (fd :: FD) :: FD where ... Source #
HomogenizeFD c (MkFD ds) = MkFD (MapSecondConst c ds) |
Constraints
type family FDAbsent (s :: Symbol) (fd :: FD) :: Constraint where ... Source #
FDAbsent s (MkFD ds) = FDAbsent1 s (MkFD ds) (Lookup1 s ds) |
type family FDFoldable (fun :: *) (fd1 :: FD) (fd2 :: FD) (m :: *) where ... Source #
FDFoldable fun fd1 fd2 m = (FDPure fun fd1, FDSplat fd1 fd2 (HomogenizeFD m fd2), FDHomogenous m (HomogenizeFD m fd2), Monoid m, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R (HomogenizeFD m fd2))) |
type family FDFoldable2 (fun :: *) (fd1 :: FD) (fd2 :: FD) (fd3 :: FD) (m :: *) where ... Source #
FDFoldable2 fun fd1 fd2 fd3 m = (FDPure fun fd1, FDSplat fd1 fd2 fd3, FDSplat fd3 fd2 (HomogenizeFD m fd2), FDHomogenous m (HomogenizeFD m fd2), Monoid m, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3), UnifyShape (R fd2) (R (HomogenizeFD m fd2))) |
type family FDHomogenous (a :: *) (fd :: FD) :: Constraint where ... Source #
Every field in fd
has the same type, a
.
FDHomogenous a fd = (FDHomogenous1 a (FieldsFD fd), Hoid MkFD fd) |
type family FDPure (a :: *) (fd :: FD) :: Constraint where ... Source #
The type and value of a
determine the type and value of every
field in fd
.
type family FDSplat (fd1 :: FD) (fd2 :: FD) (fd3 :: FD) :: Constraint where ... Source #
Each field in fd1
is a function from the same field in fd2
to
the same field in fd3
.
FDSplat (MkFD ds1) (MkFD ds2) (MkFD ds3) = FDSplat1 ds1 ds2 ds3 |
type family FDSplatA (i :: * -> *) (fd1 :: FD) (fd2 :: FD) (fd3 :: FD) :: Constraint where ... Source #
Each field in fd1
is a function from the same field in fd2
to
an i
-structure of the same field in fd3
.
FDSplatA i (MkFD ds1) (MkFD ds2) (MkFD ds3) = FDSplatA1 i ds1 ds2 ds3 |
fdIdentities :: forall s fd a. '(LookupFD s (InsertFD s a fd), InsertFD s (LookupFD s fd) fd, DeleteFD s (DeleteFD s fd), InsertFD s a (DeleteFD s fd), Lookup1 s (FieldsFD (DeleteFD s fd)), MkFD (FirstHalf (FieldsFD fd)) `PlusFD` MkFD (SecondHalf (FieldsFD fd))) :~: '(a, fd, DeleteFD s fd, InsertFD s a fd, Nothing, fd) Source #
This type equality provides a "proof by fiat" of some obvious identities involving the fields declarations combinators.
You typically won't need to use this.
Anonymous records
A record with fields declarations fd ::
is a product type
with one factor per declared field.FD
ClosedHas s (R fd) => Has s (R fd) Source # | |
KnownSymbol s => HasCase s (R fd) Source # | |
FDFoldable2 REq ex1 fd ex3 All => Eq (R fd) Source # | |
(Eq (R fd), FDFoldable2 RCompare ex1 fd ex3 Ordering) => Ord (R fd) Source # | |
FDFoldable RShowField ex1 fd [String] => Show (R fd) Source # | |
(Hoid FD ([(Symbol, *)] -> FD) MkFD fd, GenericDs (FieldsFD fd)) => Generic (R fd) Source # | Beware: these conversions are inefficient and very unlikely to be simplified away. |
FDFoldable RLiftField ex1 fd [ExpQ] => Lift (R fd) Source # | |
(KnownFD fd, Hoid FD ([(Symbol, *)] -> FD) MkFD fd) => Build (R fd) Source # | |
type FieldType s (R fd) Source # | |
type FieldTypeCase s (R fd) Source # | |
type Rep (R fd) Source # | |
type Fields (R fd) Source # | |
type Shape (R fd) o Source # | |
Constructors
plusR :: R fd1 -> R fd2 -> R (PlusFD fd1 fd2) Source #
Each field that is in both records will have an undefined type.
Operations
adjustR :: (KnownSymbol s, fd1 ~ InsertFD s a fd2, fd2 ~ InsertFD s b fd1) => Label s -> (a -> b) -> R fd1 -> R fd2 Source #
extricate1R :: KnownSymbol s => Label s -> R fd -> Eval (LookupFD s fd) Source #
When forced, this Eval
computation extricates the value of the
field from the rest of the record without forcing the value of the
field itself. See extricate1
for further motivation.
lensR :: (KnownSymbol s, fd1 ~ InsertFD s a fd2, fd2 ~ InsertFD s b fd1, Functor f) => Label s -> (a -> f b) -> R fd1 -> f (R fd2) Source #
Fieldwise operations
data RShowField Source #
For example:
*Data.Ruin.R> mapM_ putStrLn $rfoldMapR
MkRShowField
$oneR
#x "x" `plusR
`oneR
#y () x = "x" y = ()
(KnownSymbol s, Show a, (~) * b (a -> [String])) => FPure RShowField s b Source # | |
rfoldR :: (Monoid m, FDHomogenous m fd) => R fd -> m Source #
Beware: the order in which the fields are combined is undefined,
so the Monoid
ought to be commutative.
rfoldMapR :: forall fd1 fd2 fun m. FDFoldable fun fd1 fd2 m => fun -> R fd2 -> m Source #
rfoldMap2R :: forall fd1 fd2 fd3 fun m. FDFoldable2 fun fd1 fd2 fd3 m => fun -> R fd2 -> R fd2 -> m Source #
rmapR :: forall fd1 fd2 fd3 fun. (FDPure fun fd1, FDSplat fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => fun -> R fd2 -> R fd3 infixl 4 Source #
rmapAR :: forall fun fd1 fd2 fd3 i. (Applicative i, FDPure fun fd1, FDSplatA i fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => fun -> R fd2 -> i (R fd3) infixl 4 Source #
rsplatR :: (FDSplat fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => R fd1 -> R fd2 -> R fd3 infixl 4 Source #
rsplatAR :: (Applicative i, FDSplatA i fd1 fd2 fd3, UnifyShape (R fd1) (R fd2), UnifyShape (R fd2) (R fd3)) => R fd1 -> R fd2 -> i (R fd3) infixl 4 Source #
Monomorphic specializations
monoadjustR :: forall s fd. KnownSymbol s => Label s -> (LookupFD s fd -> LookupFD s fd) -> R fd -> R fd Source #
lens'R :: forall s fd f. (KnownSymbol s, Functor f) => Label s -> (LookupFD s fd -> f (LookupFD s fd)) -> R fd -> f (R fd) Source #
Field labels
Use -XOverloadedLabels
to create labels. For example, #x ::
Label "x"
.
Or use mkLabel
.