on master help sign in
Small cleanups
commit9abbdfaee55c47edb6551cfbcf75d47f89096fff authorBryan O'Sullivan <bos@serpentine.com> dateFri 18 Sep 2015, 09:57 (11 years ago) parent157df12
1 file changed+12−22
Data/Aeson/Encode/Builder.hs+12−22
Data/Aeson/Encode/Builder.hs+12−22
@@ -169,9 +169,9 @@ ascii8 cs = BP.liftFixedToBounded $ (const cs) >$<
169169{-# INLINE ascii8 #-}
170170
171171day :: Day -> Builder
172−day dd = encodeYear y <>
172+day dd = encodeYear yr <>
173173 BP.primBounded (ascii6 ('-',(mh,(ml,('-',(dh,dl)))))) ()
174− where (y,m,d) = toGregorian dd
174+ where (yr,m,d) = toGregorian dd
175175 !(T mh ml) = twoDigits m
176176 !(T dh dl) = twoDigits d
177177 encodeYear y
@@ -198,30 +198,20 @@ timeOfDay64 (TOD h m s)
198198 !(T mh ml) = twoDigits m
199199 !(T sh sl) = twoDigits (fromIntegral real)
200200 (real,frac) = s `quotRem` pico
201−
202201 showFrac = (\x -> ('.', x)) >$< (BP.liftFixedToBounded BP.char7 >*< trunc12)
203−
204− trunc12 =
205− (`quotRem` micro) >$<
206− BP.condB (\(_,y) -> y == 0) (fst >$< trunc6) (digits6 >*< trunc6)
207−
202+ trunc12 = (`quotRem` micro) >$<
203+ BP.condB (\(_,y) -> y == 0) (fst >$< trunc6) (digits6 >*< trunc6)
208204 digits6 = ((`quotRem` milli) . fromIntegral) >$< (digits3 >*< digits3)
209−
210− trunc6 =
211− ((`quotRem` milli) . fromIntegral) >$<
212− BP.condB (\(_,y) -> y == 0) (fst >$< trunc3) (digits3 >*< trunc3)
213−
214− digits3 = ((`quotRem` 10) >$< (digits2 >*< digits1))
215−
205+ trunc6 = ((`quotRem` milli) . fromIntegral) >$<
206+ BP.condB (\(_,y) -> y == 0) (fst >$< trunc3) (digits3 >*< trunc3)
207+ digits3 = (`quotRem` 10) >$< (digits2 >*< digits1)
216208 digits2 = (`quotRem` 10) >$< (digits1 >*< digits1)
217−
218209 digits1 = BP.liftFixedToBounded (digit >$< BP.char7)
219−
220− trunc3 = BP.condB (== 0) BP.emptyB $
221− ((`quotRem` 100) >$< (digits1 >*< trunc2))
222− trunc2 = BP.condB (== 0) BP.emptyB $
223− ((`quotRem` 10) >$< (digits1 >*< trunc1))
224− trunc1 = BP.condB (== 0) BP.emptyB digits1
210+ trunc3 = BP.condB (== 0) BP.emptyB $
211+ (`quotRem` 100) >$< (digits1 >*< trunc2)
212+ trunc2 = BP.condB (== 0) BP.emptyB $
213+ (`quotRem` 10) >$< (digits1 >*< trunc1)
214+ trunc1 = BP.condB (== 0) BP.emptyB digits1
225215
226216 pico = 1000000000000 -- number of picoseconds in 1 second
227217 micro = 1000000 -- number of microseconds in 1 second