Data.Lens.Barlow.Internal
- Package
- purescript-barlow-lens
- Repository
- sigma-andex/purescript-barlow-lens
Type-level helpers used by the barlow lens construction.
#Unreachable Source
class Unreachable whereA class without instances, so it can only ever be satisfied as a given constraint.
Instances whose context contains a Fail (and therefore can never be selected)
also require Unreachable, which lets them use unreachable as a body.
Members
unreachable :: forall a. a
#FieldOf Source
class FieldOf :: Symbol -> Row Type -> Type -> Row Type -> Constraintclass FieldOf (sym :: Symbol) (r :: Row Type) a (rest :: Row Type) | sym r -> a rest where
Row.Cons sym a rest r, but failing with a readable message if the field doesn't exist.
The Row.Cons is only solved once the field is known to exist; otherwise the compiler
would report a unification error before ever reaching the custom error.
Members
getField :: Proxy sym -> Record r -> asetField :: Proxy sym -> a -> Record r -> Record rfieldLens :: forall p b r'. Strong p => Cons sym b rest r' => Proxy sym -> p a b -> p (Record r) (Record r')
Instances
#FieldOfRL Source
class FieldOfRL :: Symbol -> RowList Type -> Row Type -> Type -> Row Type -> Constraintclass FieldOfRL (sym :: Symbol) (rl :: RowList Type) (r :: Row Type) a (rest :: Row Type) | sym rl r -> a rest where
Members
getFieldRL :: Proxy sym -> Proxy rl -> Record r -> asetFieldRL :: Proxy sym -> Proxy rl -> a -> Record r -> Record rfieldLensRL :: forall p b r'. Strong p => Cons sym b rest r' => Proxy sym -> Proxy rl -> p a b -> p (Record r) (Record r')
Instances
(IsSymbol sym, Cons sym a rest r) => FieldOfRL sym (Cons sym a tail) r a rest(Fail (Above (Beside (Text "barlow: the field ") (Beside (QuoteLabel sym) (Text " does not exist in the record"))) (Quote (Record r))), Unreachable) => FieldOfRL sym Nil r a rest(FieldOfRL sym tail r a rest) => FieldOfRL sym (Cons other b tail) r a rest
#IndexKey Source
#ParseIntAcc Source
class ParseIntAcc :: Symbol -> Symbol -> Int -> Int -> Constraintclass ParseIntAcc (original :: Symbol) (sym :: Symbol) (acc :: Int) (n :: Int) | original sym acc -> n
Instances
ParseIntAcc original "" acc acc(Cons h t sym, Digit original h d, Mul acc 10 acc10, Add acc10 d acc', ParseIntAcc original t acc' n) => ParseIntAcc original sym acc n
#Digit Source
#SelectFields Source
class SelectFields :: TList -> Row Type -> Row Type -> Constraintclass SelectFields (fields :: TList) (r :: Row Type) (sub :: Row Type) | fields r -> sub where
Members
getFields :: Proxy fields -> Record r -> Builder (Record ()) (Record sub)setFields :: Proxy fields -> Record sub -> Record r -> Record r
Instances
SelectFields TNil r ()(IsSymbol f, FieldOf f r a rx, SelectFields rest r subRest, Lacks f subRest, Cons f a subRest sub) => SelectFields (TCons f rest) r sub
#selectFields Source
selectFields :: forall fields r sub. SelectFields fields r sub => Proxy fields -> Lens' (Record r) (Record sub)A lens onto the sub-record containing only the given fields.
#traverseRecord Source
traverseRecord :: forall @a rl r. TraverseFields rl r a => Proxy rl -> Traversal' (Record r) aTraverses all fields of a homogeneous record.
#itraverseRecord Source
itraverseRecord :: forall @a rl r. TraverseFields rl r a => Proxy rl -> IndexedTraversal' String (Record r) aTraverses all fields of a homogeneous record, indexed by field name.
#RecordElem Source
class RecordElem :: RowList Type -> Type -> Constraintclass RecordElem (rl :: RowList Type) (a :: Type) | rl -> a
The type of the first field, i.e. the element type of a homogeneous record.
Instances
RecordElem (Cons l a tail) aRecordElem Nil a
#TraverseFields Source
class TraverseFields :: RowList Type -> Row Type -> Type -> Constraintclass TraverseFields (rl :: RowList Type) (r :: Row Type) a where
Has no functional dependency on purpose, so a field of the wrong type falls through to the custom error.
Members
traverseFields :: forall f. Applicative f => Proxy rl -> (String -> a -> f a) -> Record r -> f (Record r)
Instances
TraverseFields Nil r a(IsSymbol l, Cons l a rx r, TraverseFields tail r a) => TraverseFields (Cons l a tail) r a(Fail (Above (Text "barlow: `+` and `#` on a record need all fields to have the same type, but") (Beside (Text "the field ") (Beside (QuoteLabel l) (Beside (Text " has type ") (Beside (Quote b) (Beside (Text " instead of ") (Quote a)))))))) => TraverseFields (Cons l b tail) r a