-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Data.Lens.Record.VTA (prop) where | ||
|
||
import Data.Lens (Lens) | ||
import Data.Symbol (class IsSymbol) | ||
import Prim.Row as Row | ||
import Type.Proxy (Proxy(..)) | ||
import Data.Lens.Record as Data.Lens.Record | ||
|
||
-- | Construct a (type-changing) lens for a record property, by providing a | ||
-- | `Symbol` via VTA (visible type application) which corresponds to the | ||
-- | property label. | ||
-- | | ||
-- | The lens is polymorphic in the rest of the row of property labels. | ||
-- | | ||
-- | For example: | ||
-- | | ||
-- | ```purescript | ||
-- | prop @"foo" | ||
-- | :: forall a b r. Lens { foo :: a | r } { foo :: b | r } a b | ||
-- | ``` | ||
prop | ||
:: forall @l r1 r2 r a b | ||
. IsSymbol l | ||
=> Row.Cons l a r r1 | ||
=> Row.Cons l b r r2 | ||
=> Lens (Record r1) (Record r2) a b | ||
prop = Data.Lens.Record.prop (Proxy @l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters