{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Data.Record.Anon.Advanced (
Record
, empty
, insert
, insertA
, applyPending
, get
, set
, project
, inject
, lens
, merge
, map
, cmap
, pure
, cpure
, ap
, collapse
, toList
, mapM
, cmapM
, sequenceA
, sequenceA'
, distribute
, distribute'
, zip
, zipWith
, zipWithM
, czipWith
, czipWithM
, reifyAllFields
, reflectAllFields
, reifyKnownFields
, reflectKnownFields
, A.InRow(..)
, reifySubRow
, reflectSubRow
, A.SomeRecord(..)
, someRecord
, letRecordT
, letInsertAs
, castEqual
) where
import Prelude hiding (sequenceA, map, mapM, pure, zip, zipWith)
import TypeLet (Let, Equal)
import qualified TypeLet
import Data.Record.Anon
import Data.Record.Anon.Internal.Advanced (Record)
import qualified Data.Record.Anon.Internal.Advanced as A
empty :: Record f '[]
empty :: forall {k} (f :: k -> *). Record f '[]
empty = forall {k} (f :: k -> *). Record f '[]
A.empty
insert :: Field n -> f a -> Record f r -> Record f (n := a : r)
insert :: forall {b} (n :: Symbol) (f :: b -> *) (a :: b) (r :: Row b).
Field n -> f a -> Record f r -> Record f ((n ':= a) : r)
insert = forall k (f :: k -> *) (r :: Row k) (a :: k) (n :: Symbol).
Field n -> f a -> Record f r -> Record f ((n ':= a) : r)
A.insert
insertA ::
Applicative m
=> Field n -> m (f a) -> m (Record f r) -> m (Record f (n ':= a : r))
insertA :: forall {b} (m :: * -> *) (n :: Symbol) (f :: b -> *) (a :: b)
(r :: Row b).
Applicative m =>
Field n
-> m (f a) -> m (Record f r) -> m (Record f ((n ':= a) : r))
insertA = forall {b} (m :: * -> *) (n :: Symbol) (f :: b -> *) (a :: b)
(r :: Row b).
Applicative m =>
Field n
-> m (f a) -> m (Record f r) -> m (Record f ((n ':= a) : r))
A.insertA
applyPending :: Record f r -> Record f r
applyPending :: forall {k} (f :: k -> *) (r :: Row k). Record f r -> Record f r
applyPending = forall {k} (f :: k -> *) (r :: Row k). Record f r -> Record f r
A.applyPending
get :: RowHasField n r a => Field n -> Record f r -> f a
get :: forall {k} (n :: Symbol) (r :: Row k) (a :: k) (f :: k -> *).
RowHasField n r a =>
Field n -> Record f r -> f a
get = forall {k} (n :: Symbol) (f :: k -> *) (r :: Row k) (a :: k).
RowHasField n r a =>
Field n -> Record f r -> f a
A.get
set :: RowHasField n r a => Field n -> f a -> Record f r -> Record f r
set :: forall {k} (n :: Symbol) (r :: Row k) (a :: k) (f :: k -> *).
RowHasField n r a =>
Field n -> f a -> Record f r -> Record f r
set = forall {k} (n :: Symbol) (f :: k -> *) (r :: Row k) (a :: k).
RowHasField n r a =>
Field n -> f a -> Record f r -> Record f r
A.set
project :: SubRow r r' => Record f r -> Record f r'
project :: forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *).
SubRow r r' =>
Record f r -> Record f r'
project = forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *).
SubRow r r' =>
Record f r -> Record f r'
A.project
inject :: SubRow r r' => Record f r' -> Record f r -> Record f r
inject :: forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *).
SubRow r r' =>
Record f r' -> Record f r -> Record f r
inject = forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *).
SubRow r r' =>
Record f r' -> Record f r -> Record f r
A.inject
lens ::
SubRow r r'
=> Record f r -> (Record f r', Record f r' -> Record f r)
lens :: forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *).
SubRow r r' =>
Record f r -> (Record f r', Record f r' -> Record f r)
lens = forall {k} (f :: k -> *) (r :: Row k) (r' :: Row k).
SubRow r r' =>
Record f r -> (Record f r', Record f r' -> Record f r)
A.lens
merge :: Record f r -> Record f r' -> Record f (Merge r r')
merge :: forall {k} (f :: k -> *) (r :: Row k) (r' :: Row k).
Record f r -> Record f r' -> Record f (Merge r r')
merge = forall {k} (f :: k -> *) (r :: Row k) (r' :: Row k).
Record f r -> Record f r' -> Record f (Merge r r')
A.merge
map :: (forall x. f x -> g x) -> Record f r -> Record g r
map :: forall {k} (f :: k -> *) (g :: k -> *) (r :: Row k).
(forall (x :: k). f x -> g x) -> Record f r -> Record g r
map forall (x :: k). f x -> g x
f = forall {k} (f :: k -> *) (g :: k -> *) (r :: Row k).
(forall (x :: k). f x -> g x) -> Record f r -> Record g r
A.map forall (x :: k). f x -> g x
f
mapM :: Applicative m => (forall x. f x -> m (g x)) -> Record f r -> m (Record g r)
mapM :: forall {k} (m :: * -> *) (f :: k -> *) (g :: k -> *) (r :: Row k).
Applicative m =>
(forall (x :: k). f x -> m (g x)) -> Record f r -> m (Record g r)
mapM forall (x :: k). f x -> m (g x)
f = forall {k} (m :: * -> *) (f :: k -> *) (g :: k -> *) (r :: Row k).
Applicative m =>
(forall (x :: k). f x -> m (g x)) -> Record f r -> m (Record g r)
A.mapM forall (x :: k). f x -> m (g x)
f
cmap ::
AllFields r c
=> Proxy c -> (forall x. c x => f x -> g x) -> Record f r -> Record g r
cmap :: forall {k} (r :: Row k) (c :: k -> Constraint) (f :: k -> *)
(g :: k -> *).
AllFields r c =>
Proxy c
-> (forall (x :: k). c x => f x -> g x) -> Record f r -> Record g r
cmap Proxy c
p forall (x :: k). c x => f x -> g x
f = forall {k} (r :: Row k) (c :: k -> Constraint) (f :: k -> *)
(g :: k -> *).
AllFields r c =>
Proxy c
-> (forall (x :: k). c x => f x -> g x) -> Record f r -> Record g r
A.cmap Proxy c
p forall (x :: k). c x => f x -> g x
f
cmapM ::
(Applicative m, AllFields r c)
=> Proxy c
-> (forall x. c x => f x -> m (g x))
-> Record f r -> m (Record g r)
cmapM :: forall {k} (m :: * -> *) (r :: Row k) (c :: k -> Constraint)
(f :: k -> *) (g :: k -> *).
(Applicative m, AllFields r c) =>
Proxy c
-> (forall (x :: k). c x => f x -> m (g x))
-> Record f r
-> m (Record g r)
cmapM Proxy c
p forall (x :: k). c x => f x -> m (g x)
f = forall {k} (m :: * -> *) (r :: Row k) (c :: k -> Constraint)
(f :: k -> *) (g :: k -> *).
(Applicative m, AllFields r c) =>
Proxy c
-> (forall (x :: k). c x => f x -> m (g x))
-> Record f r
-> m (Record g r)
A.cmapM Proxy c
p forall (x :: k). c x => f x -> m (g x)
f
pure :: KnownFields r => (forall x. f x) -> Record f r
pure :: forall {k} (r :: Row k) (f :: k -> *).
KnownFields r =>
(forall (x :: k). f x) -> Record f r
pure forall (x :: k). f x
f = forall {k} (f :: k -> *) (r :: Row k).
KnownFields r =>
(forall (x :: k). f x) -> Record f r
A.pure forall (x :: k). f x
f
cpure :: AllFields r c => Proxy c -> (forall x. c x => f x) -> Record f r
cpure :: forall {k} (r :: Row k) (c :: k -> Constraint) (f :: k -> *).
AllFields r c =>
Proxy c -> (forall (x :: k). c x => f x) -> Record f r
cpure Proxy c
p forall (x :: k). c x => f x
f = forall {k} (r :: Row k) (f :: k -> *) (c :: k -> Constraint).
AllFields r c =>
Proxy c -> (forall (x :: k). c x => f x) -> Record f r
A.cpure Proxy c
p forall (x :: k). c x => f x
f
ap :: Record (f -.-> g) r -> Record f r -> Record g r
ap :: forall {k} (f :: k -> *) (g :: k -> *) (r :: Row k).
Record (f -.-> g) r -> Record f r -> Record g r
ap = forall {k} (f :: k -> *) (g :: k -> *) (r :: Row k).
Record (f -.-> g) r -> Record f r -> Record g r
A.ap
collapse :: Record (K a) r -> [a]
collapse :: forall {k} a (r :: Row k). Record (K a) r -> [a]
collapse = forall {k} a (r :: Row k). Record (K a) r -> [a]
A.collapse
toList :: KnownFields r => Record (K a) r -> [(String, a)]
toList :: forall {k} (r :: Row k) a.
KnownFields r =>
Record (K a) r -> [(String, a)]
toList = forall {k} (r :: Row k) a.
KnownFields r =>
Record (K a) r -> [(String, a)]
A.toList
sequenceA :: Applicative m => Record (m :.: f) r -> m (Record f r)
sequenceA :: forall {k} (m :: * -> *) (f :: k -> *) (r :: Row k).
Applicative m =>
Record (m :.: f) r -> m (Record f r)
sequenceA = forall {k} (m :: * -> *) (f :: k -> *) (r :: Row k).
Applicative m =>
Record (m :.: f) r -> m (Record f r)
A.sequenceA
sequenceA' :: Applicative m => Record m r -> m (Record I r)
sequenceA' :: forall (m :: * -> *) (r :: Row (*)).
Applicative m =>
Record m r -> m (Record I r)
sequenceA' = forall (m :: * -> *) (r :: Row (*)).
Applicative m =>
Record m r -> m (Record I r)
A.sequenceA'
distribute :: (Functor m, KnownFields r) => m (Record f r) -> Record (m :.: f) r
distribute :: forall {k} (m :: * -> *) (r :: Row k) (f :: k -> *).
(Functor m, KnownFields r) =>
m (Record f r) -> Record (m :.: f) r
distribute = forall {k} (r :: Row k) (m :: * -> *) (f :: k -> *).
(Functor m, KnownFields r) =>
m (Record f r) -> Record (m :.: f) r
A.distribute
distribute' :: (Functor m, KnownFields r) => m (Record I r) -> Record m r
distribute' :: forall (m :: * -> *) (r :: Row (*)).
(Functor m, KnownFields r) =>
m (Record I r) -> Record m r
distribute' = forall (m :: * -> *) (r :: Row (*)).
(Functor m, KnownFields r) =>
m (Record I r) -> Record m r
A.distribute'
zip :: Record f r -> Record g r -> Record (Product f g) r
zip :: forall {k} (f :: k -> *) (r :: Row k) (g :: k -> *).
Record f r -> Record g r -> Record (Product f g) r
zip = forall {k} (f :: k -> *) (r :: Row k) (g :: k -> *).
Record f r -> Record g r -> Record (Product f g) r
A.zip
zipWith ::
(forall x. f x -> g x -> h x)
-> Record f r -> Record g r -> Record h r
zipWith :: forall {k} (f :: k -> *) (g :: k -> *) (h :: k -> *) (r :: Row k).
(forall (x :: k). f x -> g x -> h x)
-> Record f r -> Record g r -> Record h r
zipWith forall (x :: k). f x -> g x -> h x
f = forall {k} (f :: k -> *) (g :: k -> *) (h :: k -> *) (r :: Row k).
(forall (x :: k). f x -> g x -> h x)
-> Record f r -> Record g r -> Record h r
A.zipWith forall (x :: k). f x -> g x -> h x
f
zipWithM ::
Applicative m
=> (forall x. f x -> g x -> m (h x))
-> Record f r -> Record g r -> m (Record h r)
zipWithM :: forall {k} (m :: * -> *) (f :: k -> *) (g :: k -> *) (h :: k -> *)
(r :: Row k).
Applicative m =>
(forall (x :: k). f x -> g x -> m (h x))
-> Record f r -> Record g r -> m (Record h r)
zipWithM forall (x :: k). f x -> g x -> m (h x)
f = forall {k} (m :: * -> *) (f :: k -> *) (g :: k -> *) (h :: k -> *)
(r :: Row k).
Applicative m =>
(forall (x :: k). f x -> g x -> m (h x))
-> Record f r -> Record g r -> m (Record h r)
A.zipWithM forall (x :: k). f x -> g x -> m (h x)
f
czipWith ::
AllFields r c
=> Proxy c
-> (forall x. c x => f x -> g x -> h x)
-> Record f r -> Record g r -> Record h r
czipWith :: forall {k} (r :: Row k) (c :: k -> Constraint) (f :: k -> *)
(g :: k -> *) (h :: k -> *).
AllFields r c =>
Proxy c
-> (forall (x :: k). c x => f x -> g x -> h x)
-> Record f r
-> Record g r
-> Record h r
czipWith Proxy c
p forall (x :: k). c x => f x -> g x -> h x
f = forall {k} (r :: Row k) (c :: k -> Constraint) (f :: k -> *)
(g :: k -> *) (h :: k -> *).
AllFields r c =>
Proxy c
-> (forall (x :: k). c x => f x -> g x -> h x)
-> Record f r
-> Record g r
-> Record h r
A.czipWith Proxy c
p forall (x :: k). c x => f x -> g x -> h x
f
czipWithM ::
(Applicative m, AllFields r c)
=> Proxy c
-> (forall x. c x => f x -> g x -> m (h x))
-> Record f r -> Record g r -> m (Record h r)
czipWithM :: forall {k} (m :: * -> *) (r :: Row k) (c :: k -> Constraint)
(f :: k -> *) (g :: k -> *) (h :: k -> *).
(Applicative m, AllFields r c) =>
Proxy c
-> (forall (x :: k). c x => f x -> g x -> m (h x))
-> Record f r
-> Record g r
-> m (Record h r)
czipWithM Proxy c
p forall (x :: k). c x => f x -> g x -> m (h x)
f = forall {k} (m :: * -> *) (r :: Row k) (c :: k -> Constraint)
(f :: k -> *) (g :: k -> *) (h :: k -> *).
(Applicative m, AllFields r c) =>
Proxy c
-> (forall (x :: k). c x => f x -> g x -> m (h x))
-> Record f r
-> Record g r
-> m (Record h r)
A.czipWithM Proxy c
p forall (x :: k). c x => f x -> g x -> m (h x)
f
reifyAllFields :: AllFields r c => proxy c -> Record (Dict c) r
reifyAllFields :: forall {k} (r :: Row k) (c :: k -> Constraint)
(proxy :: (k -> Constraint) -> *).
AllFields r c =>
proxy c -> Record (Dict c) r
reifyAllFields = forall {k} (r :: Row k) (c :: k -> Constraint)
(proxy :: (k -> Constraint) -> *).
AllFields r c =>
proxy c -> Record (Dict c) r
A.reifyAllFields
reflectAllFields :: Record (Dict c) r -> Reflected (AllFields r c)
reflectAllFields :: forall {k} (c :: k -> Constraint) (r :: Row k).
Record (Dict c) r -> Reflected (AllFields r c)
reflectAllFields = forall {k} (c :: k -> Constraint) (r :: Row k).
Record (Dict c) r -> Reflected (AllFields r c)
A.reflectAllFields
reifyKnownFields :: KnownFields r => proxy r -> Record (K String) r
reifyKnownFields :: forall {k} (r :: Row k) (proxy :: Row k -> *).
KnownFields r =>
proxy r -> Record (K String) r
reifyKnownFields = forall {k} (r :: Row k) (proxy :: Row k -> *).
KnownFields r =>
proxy r -> Record (K String) r
A.reifyKnownFields
reflectKnownFields :: Record (K String) r -> Reflected (KnownFields r)
reflectKnownFields :: forall {k} (r :: Row k).
Record (K String) r -> Reflected (KnownFields r)
reflectKnownFields = forall {k} (r :: Row k).
Record (K String) r -> Reflected (KnownFields r)
A.reflectKnownFields
reifySubRow :: (KnownFields r', SubRow r r') => Record (A.InRow r) r'
reifySubRow :: forall {k} (r' :: Row k) (r :: Row k).
(KnownFields r', SubRow r r') =>
Record (InRow r) r'
reifySubRow = forall k (r :: Row k) (r' :: Row k).
(SubRow r r', KnownFields r') =>
Record (InRow r) r'
A.reifySubRow
reflectSubRow :: Record (A.InRow r) r' -> Reflected (SubRow r r')
reflectSubRow :: forall {k} (r :: Row k) (r' :: Row k).
Record (InRow r) r' -> Reflected (SubRow r r')
reflectSubRow = forall {k} (r :: Row k) (r' :: Row k).
Record (InRow r) r' -> Reflected (SubRow r r')
A.reflectSubRow
someRecord :: [(String, Some f)] -> A.SomeRecord f
someRecord :: forall {k} (f :: k -> *). [(String, Some f)] -> SomeRecord f
someRecord = forall {k} (f :: k -> *). [(String, Some f)] -> SomeRecord f
A.someRecord
letRecordT :: forall r f.
(forall r'. Let r' r => Proxy r' -> Record f r)
-> Record f r
letRecordT :: forall {k} (r :: Row k) (f :: k -> *).
(forall (r' :: Row k). Let r' r => Proxy r' -> Record f r)
-> Record f r
letRecordT forall (r' :: Row k). Let r' r => Proxy r' -> Record f r
f = forall {k} (r :: Row k) (f :: k -> *).
(forall (r' :: Row k). Let r' r => Proxy r' -> Record f r)
-> Record f r
A.letRecordT forall (r' :: Row k). Let r' r => Proxy r' -> Record f r
f
letInsertAs :: forall r r' f n a.
Proxy r
-> Field n
-> f a
-> Record f r'
-> (forall r''. Let r'' (n := a : r') => Record f r'' -> Record f r)
-> Record f r
letInsertAs :: forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *) (n :: Symbol)
(a :: k).
Proxy r
-> Field n
-> f a
-> Record f r'
-> (forall (r'' :: Row k).
Let r'' ((n ':= a) : r') =>
Record f r'' -> Record f r)
-> Record f r
letInsertAs Proxy r
p Field n
n f a
x Record f r'
r forall (r'' :: Row k).
Let r'' ((n ':= a) : r') =>
Record f r'' -> Record f r
f = forall {k} (r :: Row k) (r' :: Row k) (f :: k -> *) (n :: Symbol)
(a :: k).
Proxy r
-> Field n
-> f a
-> Record f r'
-> (forall (r'' :: Row k).
Let r'' ((n ':= a) : r') =>
Record f r'' -> Record f r)
-> Record f r
A.letInsertAs Proxy r
p Field n
n f a
x Record f r'
r forall (r'' :: Row k).
Let r'' ((n ':= a) : r') =>
Record f r'' -> Record f r
f
castEqual :: Equal a b => a -> b
castEqual :: forall a b. Equal a b => a -> b
castEqual = forall a b. Equal a b => a -> b
TypeLet.castEqual