lens-datetime 0.2.1 → 0.3
raw patch · 4 files changed
+70/−5 lines, 4 files
Files
- .gitignore +10/−2
- Data/Time/Lens.hs +21/−0
- lens-datetime.cabal +4/−3
- stack.yaml +35/−0
.gitignore view
@@ -1,4 +1,12 @@-dist+/dist+/.stack-work+*~ *.o *.hi-*~+*.chi+*.chs.h+/.virthualenv+/.hsenv+/.cabal-sandbox/+/cabal.sandbox.config+/cabal.config
Data/Time/Lens.hs view
@@ -140,6 +140,7 @@ -- * Miscellaneous , utcInTZ , utcAsLocal+ , zonedAsLocal , julianDay , julianDT , gregorianDate@@ -152,6 +153,9 @@ import Data.Time.Clock import Data.Time.LocalTime +-- To avoid the 'redundant import' warning for Applicative:+import Prelude+ -------------------------------------------------------------------------------- -- 'Flexible' data types to properly implement rolling-over behavior. @@ -217,6 +221,10 @@ flexDT = utcAsLocal.flexDT {-# INLINE flexDT #-} +instance FlexibleDateTime ZonedTime where+ flexDT = zonedAsLocal . flexDT+ {-# INLINE flexDT #-}+ -- | Type class to provide correct roll-over behavior for date lenses. -- -- Used exactly as 'flexDT', but for values that have only \"date\"@@ -289,6 +297,10 @@ date f (LocalTime d t) = flip LocalTime t <$> f d {-# INLINE date #-} +instance Dateable ZonedTime where+ date = zonedAsLocal . date+ {-# INLINE date #-}+ instance Dateable Day where date = id {-# INLINE date #-}@@ -389,6 +401,10 @@ time f (LocalTime d t) = LocalTime d <$> f t {-# INLINE time #-} +instance Timeable ZonedTime where+ time = zonedAsLocal . time+ {-# INLINE time #-}+ instance Timeable TimeOfDay where time = id {-# INLINE time #-}@@ -446,3 +462,8 @@ utcInTZ :: TimeZone -> Iso' UTCTime LocalTime utcInTZ tz = iso (utcToLocalTime tz) (localTimeToUTC tz) {-# INLINE utcInTZ #-}++-- | Lens into the 'LocalTime' part of 'ZonedTime'.+zonedAsLocal :: Lens' ZonedTime LocalTime+zonedAsLocal f (ZonedTime lt tz) = flip ZonedTime tz <$> f lt+{-# INLINE zonedAsLocal #-}
lens-datetime.cabal view
@@ -1,5 +1,5 @@ name: lens-datetime-version: 0.2.1+version: 0.3 license: BSD3 license-file: LICENSE author: Mihaly Barasz <klao@nilcons.com>@@ -8,8 +8,8 @@ cabal-version: >= 1.6 category: Data, Lenses stability: experimental-homepage: http://github.com/nilcons/lens-datetime-bug-reports: http://github.com/nilcons/lens-datetime/issues+homepage: https://github.com/nilcons/lens-datetime+bug-reports: https://github.com/nilcons/lens-datetime/issues synopsis: Lenses for Data.Time.* types description:@@ -60,6 +60,7 @@ extra-source-files: README.md+ stack.yaml .gitignore source-repository head
+ stack.yaml view
@@ -0,0 +1,35 @@+# For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration/++# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)+resolver: lts-5.14++# Local packages, usually specified by relative directory name+packages:+- '.'++# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)+extra-deps: []++# Override default flag values for local packages and extra-deps+flags: {}++# Extra package databases containing global packages+extra-package-dbs: []++# Control whether we use the GHC we find on the path+# system-ghc: true++# Require a specific version of stack, using version ranges+# require-stack-version: -any # Default+# require-stack-version: >= 1.0.0++# Override the architecture used by stack, especially useful on Windows+# arch: i386+# arch: x86_64++# Extra directories used by stack for building+# extra-include-dirs: [/path/to/dir]+# extra-lib-dirs: [/path/to/dir]++# Allow a newer minor version of GHC than the snapshot specifies+# compiler-check: newer-minor