Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
273f63f7
Commit
273f63f7
authored
Feb 28, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LensTest]
parent
86444f97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
LensTest.purs
src/LensTest.purs
+60
-0
No files found.
src/LensTest.purs
0 → 100644
View file @
273f63f7
module LensTest where
import Prelude
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Lens
import Effect
import Effect.Console
newtype S =
S {
first :: String
, last :: String
}
derive instance genericS :: Generic S _
instance showS :: Show S where
show = genericShow
defaultS :: S
defaultS =
S {
first: "First"
, last: "Last"
}
newtype T =
T {
s :: S
}
derive instance genericT :: Generic T _
instance showT :: Show T where
show = genericShow
defaultT :: T
defaultT =
T {
s: defaultS
}
_s :: Lens' T S
_s = lens getter setter
where
getter (T {s}) = s
setter (T t) s = T $ t { s = s }
_last :: Lens' S String
_last = lens getter setter
where
getter (S {last}) = last
setter (S s) l = S $ s { last = l }
func :: T -> Lens' T String -> Effect Unit
func t l = do
logShow $ view l t
logShow $ set l "last" t
-- funcT :: T -> Effect Unit
-- funcT t = func t (_ s <<< _last)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment