[Haskell-cafe] Using lenses

Gergely Risko gergely
Thu Oct 3 10:51:48 UTC 2013


Hi Simon,

http://hackage.haskell.org/package/lens-datetime-0.2/docs/Data-Time-Lens.html

Read the top of the page.

aDay = fromGregorian 2013 08 22
aLocal = LocalTime aDay (TimeOfDay 13 45 28)
aUTC = UTCTime aDay 7458.9

>>> aLocal ^. years
2013
>>> aUTC ^. months
8
>>> aDay ^. days
22
>>> aLocal & time .~ midnight
2013-08-22 00:00:00
>>> aUTC & days .~ 1 & months .~ 1
2013-01-01 02:04:18.9 UTC
>>> aLocal & hours +~ 1            -- But see the note below!
2013-08-22 14:45:28
>>> aLocal & flexDT.months +~ 12
2014-08-22 13:45:28
>>> aUTC & flexDT.days +~ 100
2013-11-30 02:04:18.9 UTC
>>> aLocal & flexDT.minutes +~ 120
2013-08-22 15:45:28

Gergely





More information about the Haskell-Cafe mailing list