ptr 0.15.6 → 0.15.7
raw patch · 4 files changed
+39/−6 lines, 4 filesdep +time
Dependencies added: time
Files
- library/Ptr/Poking.hs +23/−1
- library/Ptr/Prelude.hs +4/−0
- ptr.cabal +2/−1
- tests/Main.hs +10/−4
library/Ptr/Poking.hs view
@@ -9,7 +9,10 @@ {-|-Efficiently composable specification of how to populate a pointer.+An efficiently composable unmaterialised specification of how to populate a pointer.++Once composed it can be materialized into a specific data-structure like ByteString or+to directly populate a pointer in some low-level API. -} data Poking = {-|@@ -117,3 +120,22 @@ asciiChar :: Char -> Poking asciiChar = word8 . fromIntegral . ord++{-# INLINABLE utcTimeInIso8601InAscii #-}+{-+2017-02-01T05:03:58Z+-}+utcTimeInIso8601InAscii :: UTCTime -> Poking+utcTimeInIso8601InAscii utcTime =+ paddedAndTrimmedAsciiIntegral 4 year <> word8 45 <> + paddedAndTrimmedAsciiIntegral 2 month <> word8 45 <>+ paddedAndTrimmedAsciiIntegral 2 day <>+ word8 84 <>+ paddedAndTrimmedAsciiIntegral 2 hour <> word8 58 <>+ paddedAndTrimmedAsciiIntegral 2 minute <> word8 58 <>+ paddedAndTrimmedAsciiIntegral 2 (round second) <>+ word8 90+ where+ LocalTime date (TimeOfDay hour minute second) = utcToLocalTime utc utcTime+ (year, month, day) = toGregorian date+
library/Ptr/Prelude.hs view
@@ -55,6 +55,10 @@ ------------------------- import Data.Text as Exports (Text) +-- time+-------------------------+import Data.Time as Exports+ -- bug ------------------------- import Bug as Exports
ptr.cabal view
@@ -1,7 +1,7 @@ name: ptr version:- 0.15.6+ 0.15.7 category: Ptr, Data synopsis:@@ -56,6 +56,7 @@ -- data: text == 1.*, bytestring >= 0.10 && < 0.11,+ time >= 1 && < 2, -- control: semigroups >= 0.18 && < 0.20, profunctors >= 5.1 && < 6,
tests/Main.hs view
@@ -29,10 +29,16 @@ , testProperty "PokeAndPeek composition" $ \input -> input === pokeAndPeek ((,) <$> lmap fst E.word8 <*> lmap snd E.beWord32) input ,- testCase "paddedAndTrimmedAsciiIntegral" $ do- assertEqual "" "001" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 1))- assertEqual "" "001" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 2001))- assertEqual "" "000" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 (-1)))+ testGroup "Poking"+ [+ testCase "paddedAndTrimmedAsciiIntegral" $ do+ assertEqual "" "001" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 1))+ assertEqual "" "001" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 2001))+ assertEqual "" "000" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 (-1)))+ ,+ testCase "utcTimeInIso8601InAscii" $ do+ assertEqual "" "2017-02-01T05:03:58Z" (A.poking (F.utcTimeInIso8601InAscii (read "2017-02-01 05:03:58")))+ ] ] pokeThenPeek :: B.Poke a -> C.Peek a -> Maybe (a -> a)