Module

Data.Lens.Barlow

Package
purescript-barlow-lens
Repository
sigma-andex/purescript-barlow-lens

#Barlow Source

class Barlow :: Symbol -> (Type -> Type -> Type) -> Type -> Type -> Type -> Type -> Constraintclass Barlow (string :: Symbol) p s t a b | string -> s t a b where

Members

Instances

#barlow Source

barlow :: forall @string lenses p s t a b. ParseSymbol string lenses => ConstructBarlow lenses p s t a b => IsSymbol string => Optic p s t a b

Type-safe lens for zooming into a deeply nested record

sky = { zodiac: { virgo: { alpha: "Spica" } } }
view (barlow @"zodiac.virgo.alpha") sky
-- Spica
over (barlow @"zodiac.virgo.alpha") toUpper sky
-- { zodiac: { virgo: { alpha: "SPICA" } } }

#ibarlow Source

ibarlow :: forall @string lenses p i s t a b. ParseSymbol string lenses => ConstructIndexed lenses p i s t a b => IndexedOptic p i s t a b

Type-safe indexed optic. Every # in the path traverses a container and remembers the position (or key) of each element. Several # combine their indices into nested tuples: Tuple (Tuple i j) k.

sky = { zodiac: [ { stars: [ "Spica", "Porrima" ] }, { stars: [ "Regulus" ] } ] }
itoListOf (ibarlow @"zodiac#.stars") sky
-- (Tuple 0 ["Spica","Porrima"]) : (Tuple 1 ["Regulus"]) : Nil
itoListOf (ibarlow @"zodiac#.stars#") sky
-- (Tuple (Tuple 0 0) "Spica") : (Tuple (Tuple 0 1) "Porrima") : (Tuple (Tuple 1 0) "Regulus") : Nil

#key Source

key :: forall k. Proxy k

Just an alias for Proxy to make selection a bit nicer