Module
Record.Studio
- Package
- purescript-record-studio
- Repository
- rowtype-yoga/purescript-record-studio
Re-exports from Record.Studio.Keys
Re-exports from Record.Studio.Map
#MapRecord Source
data MapRecord a b
Constructors
MapRecord (a -> b)
Instances
(IsSymbol sym, Lacks sym rb, Cons sym b rb rc) => FoldingWithIndex (MapRecord a b) (Proxy sym) (Builder (Record ra) (Record rb)) a (Builder (Record ra) (Record rc))
(IsSymbol sym, Lacks sym rb, RowToList x xRL, Cons sym (Record y) rb rc, FoldlRecord (MapRecord a b) (Builder (Record ()) (Record ())) xRL x (Builder (Record ()) (Record y))) => FoldingWithIndex (MapRecord a b) (Proxy sym) (Builder (Record ra) (Record rb)) (Record x) (Builder (Record ra) (Record rc))
(IsSymbol sym, Lacks sym rb, Cons sym x rb rc) => FoldingWithIndex (MapRecord a b) (Proxy sym) (Builder (Record ra) (Record rb)) x (Builder (Record ra) (Record rc))
#mapRecord Source
mapRecord :: forall a b rin rout. HFoldlWithIndex (MapRecord a b) (Builder (Record ()) (Record ())) (Record rin) (Builder (Record ()) (Record rout)) => (a -> b) -> Record rin -> Record rout
Recursively maps a record using a function f.
let
f :: Int -> String
f i = show (i + 1)
mapRecord f { a : { b : 10, c : { d: 20, e : Just "hello" }}, f : 30 }
-- { a : { b : "11", c : { d: "21", e : Just "hello" }, f : "31" }
Re-exports from Record.Studio.MapKind
#MapRecordKind Source
data MapRecordKind :: forall k. (k -> Type) -> (k -> Type) -> Type
data MapRecordKind f g
Constructors
MapRecordKind (f ~> g)
Instances
(IsSymbol sym, Lacks sym rb, Cons sym (g a) rb rc) => FoldingWithIndex (MapRecordKind f g) (Proxy sym) (Builder (Record ra) (Record rb)) (f a) (Builder (Record ra) (Record rc))
(IsSymbol sym, Lacks sym rb, RowToList x xRL, Cons sym (Record y) rb rc, FoldlRecord (MapRecordKind f g) (Builder (Record ()) (Record ())) xRL x (Builder (Record ()) (Record y))) => FoldingWithIndex (MapRecordKind f g) (Proxy sym) (Builder (Record ra) (Record rb)) (Record x) (Builder (Record ra) (Record rc))
(IsSymbol sym, Lacks sym rb, Cons sym x rb rc) => FoldingWithIndex (MapRecordKind f g) (Proxy sym) (Builder (Record ra) (Record rb)) x (Builder (Record ra) (Record rc))
#mapRecordKind Source
mapRecordKind :: forall f g rin rout. HFoldlWithIndex (MapRecordKind f g) (Builder (Record ()) (Record ())) (Record rin) (Builder (Record ()) (Record rout)) => (f ~> g) -> Record rin -> Record rout
Recursively mapK a record using a natural transformation. E.g.
let
nt :: Either String ~> Maybe
nt = hush
mapRecordKind { a : { b : { c : { d: Right 10, e : Left "hello" }, f : Right true }
-- Just { a : { b : { c : { d: Just 10, e : Nothing }, f : Just true }
Re-exports from Record.Studio.MapUniform
#MapUniformRecord Source
class MapUniformRecord :: RowList Type -> Row Type -> Type -> Type -> Row Type -> Row Type -> Constraint
class MapUniformRecord (xs :: RowList Type) (row :: Row Type) a b (from :: Row Type) (to :: Row Type) | xs -> row a b from to where
Members
Instances
MapUniformRecord Nil row a b () ()
(IsSymbol name, Cons name a rest row, Lacks name from', Cons name b from' to, MapUniformRecord tail row a b from from') => MapUniformRecord (Cons name a tail) row a b from to
#mapUniformRecord Source
mapUniformRecord :: forall row xs a b row'. RowToList row xs => MapUniformRecord xs row a b () row' => (a -> b) -> Record row -> Record row'
Re-exports from Record.Studio.Merge
#mergeFlipped Source
mergeFlipped :: forall r1 r2 r3 r4. Union r1 r2 r3 => Nub r3 r4 => Record r2 -> Record r1 -> Record r4
Like merge
but with its arguments flipped. I.e. merges two records with the seconds record's labels taking precedence in the
case of overlaps.
For example:
mergeFlipped { x: 1, y: "y" } { y: 2, z: true }
= { x: 1, y: 2, z: true }
#(//) Source
Operator alias for Record.Studio.Merge.mergeFlipped (right-associative / precedence 1)
record1 // record2
is equivalent to JS's
{ ...record1, ...record2 }
Re-exports from Record.Studio.SameKeys
Re-exports from Record.Studio.Sequence
#SequenceRecord Source
data SequenceRecord :: (Type -> Type) -> Type
data SequenceRecord (f :: Type -> Type)
Constructors
Instances
(Applicative f, IsSymbol sym, Lacks sym rb, Cons sym a rb rc) => FoldingWithIndex (SequenceRecord f) (Proxy sym) (f (Builder (Record ra) (Record rb))) (f a) (f (Builder (Record ra) (Record rc)))
(Applicative f, IsSymbol sym, Lacks sym rb, RowToList x xRL, Cons sym (Record y) rb rc, FoldlRecord (SequenceRecord f) (f (Builder (Record ()) (Record ()))) xRL x (f (Builder (Record ()) (Record y)))) => FoldingWithIndex (SequenceRecord f) (Proxy sym) (f (Builder (Record ra) (Record rb))) (Record x) (f (Builder (Record ra) (Record rc)))
(Applicative f, IsSymbol sym, Lacks sym rb, Cons sym x rb rc) => FoldingWithIndex (SequenceRecord f) (Proxy sym) (f (Builder (Record ra) (Record rb))) x (f (Builder (Record ra) (Record rc)))
#sequenceRecord Source
sequenceRecord :: forall f rin rout. Applicative f => HFoldlWithIndex (SequenceRecord f) (f (Builder (Record ()) (Record ()))) (Record rin) (f (Builder (Record ()) (Record rout))) => Record rin -> f (Record rout)
Recursively sequence a record. E.g.
sequenceRecord { a : { b : { c : { d: Just 10, e : Just "hello" }, f : Just true }
-- Just { a : { b : { c : { d: 10, e : "hello" }, f : true }
Re-exports from Record.Studio.Shrink
Re-exports from Record.Studio.SingletonRecord
#SingletonRecord Source
class SingletonRecord :: forall k1 k2. k1 -> Type -> Row Type -> k2 -> Constraint
class SingletonRecord key value rec recRL | rec -> key value recRL where
Members
Instances
(RowToList rec recRL, SingletonRecordFields key a rec recRL) => SingletonRecord key a rec rl
(Fail (Text "The record must have exactly one field")) => SingletonRecord key a rec recRL
Get the key of a record with only one field as a
Proxy