src: Lets: GetSetLens: Implement the examples
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
parent
1b68f0617f
commit
5186970bb8
1 changed files with 14 additions and 14 deletions
|
@ -466,8 +466,7 @@ addressL =
|
|||
getSuburb ::
|
||||
Person
|
||||
-> String
|
||||
getSuburb =
|
||||
error "todo: getSuburb"
|
||||
getSuburb = get $ (compose suburbL addressL)
|
||||
|
||||
-- |
|
||||
--
|
||||
|
@ -480,8 +479,7 @@ setStreet ::
|
|||
Person
|
||||
-> String
|
||||
-> Person
|
||||
setStreet =
|
||||
error "todo: setStreet"
|
||||
setStreet = set $ (compose streetL addressL)
|
||||
|
||||
-- |
|
||||
--
|
||||
|
@ -493,8 +491,8 @@ setStreet =
|
|||
getAgeAndCountry ::
|
||||
(Person, Locality)
|
||||
-> (Int, String)
|
||||
getAgeAndCountry =
|
||||
error "todo: getAgeAndCountry"
|
||||
getAgeAndCountry (person, locality) = (get ageL person,
|
||||
get countryL locality)
|
||||
|
||||
-- |
|
||||
--
|
||||
|
@ -505,8 +503,9 @@ getAgeAndCountry =
|
|||
-- (Person 28 "Mary" (Address "83 Mary Ln" "Maryland" (Locality "Some Other City" "Western Mary" "Maristan")),Address "15 Fred St" "Fredville" (Locality "Mary Mary" "Western Mary" "Maristan"))
|
||||
setCityAndLocality ::
|
||||
(Person, Address) -> (String, Locality) -> (Person, Address)
|
||||
setCityAndLocality =
|
||||
error "todo: setCityAndLocality"
|
||||
setCityAndLocality (person, address) (city, locality) =
|
||||
(set (cityL |. localityL |. addressL) person city,
|
||||
set localityL address locality)
|
||||
|
||||
-- |
|
||||
--
|
||||
|
@ -518,8 +517,9 @@ setCityAndLocality =
|
|||
getSuburbOrCity ::
|
||||
Either Address Locality
|
||||
-> String
|
||||
getSuburbOrCity =
|
||||
error "todo: getSuburbOrCity"
|
||||
getSuburbOrCity = \soc -> case soc of
|
||||
Left address -> get suburbL address
|
||||
Right locality -> get cityL locality
|
||||
|
||||
-- |
|
||||
--
|
||||
|
@ -532,8 +532,9 @@ setStreetOrState ::
|
|||
Either Person Locality
|
||||
-> String
|
||||
-> Either Person Locality
|
||||
setStreetOrState =
|
||||
error "todo: setStreetOrState"
|
||||
setStreetOrState = \sos -> \ipsos -> case sos of
|
||||
Left person -> Left $ set (streetL |. addressL) person ipsos
|
||||
Right locality -> Right $ set stateL locality ipsos
|
||||
|
||||
-- |
|
||||
--
|
||||
|
@ -545,5 +546,4 @@ setStreetOrState =
|
|||
modifyCityUppercase ::
|
||||
Person
|
||||
-> Person
|
||||
modifyCityUppercase =
|
||||
error "todo: modifyCityUppercase"
|
||||
modifyCityUppercase = (cityL |. localityL |. addressL) %~ map toUpper
|
||||
|
|
Loading…
Reference in a new issue