formatting 5.0 → 5.1
raw patch · 3 files changed
+19/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Formatting.Holey: hmap :: (m -> n) -> Holey m r a -> Holey n r a
- Formatting.Holey: newtype Holey m r a
+ Formatting.Holey: (%.) :: Holey m r (a -> b) -> Holey a b c -> Holey m r c
+ Formatting.Holey: instance Functor (HoleyT r a)
+ Formatting.Holey: newtype HoleyT r a m
+ Formatting.Holey: type Holey m r a = HoleyT r a m
- Formatting.Holey: Holey :: ((m -> r) -> a) -> Holey m r a
+ Formatting.Holey: Holey :: ((m -> r) -> a) -> HoleyT r a m
- Formatting.Holey: runHM :: Holey m r a -> (m -> r) -> a
+ Formatting.Holey: runHM :: HoleyT r a m -> (m -> r) -> a
Files
- formatting.cabal +1/−1
- src/Formatting/Holey.hs +16/−8
- src/Formatting/Time.hs +2/−1
formatting.cabal view
@@ -1,5 +1,5 @@ name: formatting-version: 5.0+version: 5.1 synopsis: Combinator-based type-safe formatting (like printf() or FORMAT) description: Combinator-based type-safe formatting (like printf() or FORMAT), modelled from the HoleyMonoids package. license: BSD3
src/Formatting/Holey.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-}@@ -17,12 +18,13 @@ ( -- * Formatting library Format,- Holey (..),+ Holey,+ HoleyT (..), (%),+ (%.), now, bind,- later,- hmap+ later ) where import Data.Monoid@@ -40,8 +42,13 @@ -- this order allows holey monoids to be composed using `.`, stacking -- the expected arguments. Note that the `Monoid` constraint is only -- used in the identity 'Holey' and in composing two 'Holey's.-newtype Holey m r a = Holey { runHM :: (m -> r) -> a }+newtype HoleyT r a m = Holey { runHM :: (m -> r) -> a } +type Holey m r a = HoleyT r a m++instance Functor (HoleyT r a) where+ fmap g m = Holey (\k -> runHM m (k . g))+ -- | Very useful instance for writing format string. instance (IsString m, a ~ r) => IsString (Holey m r a) where fromString = now . fromString@@ -50,6 +57,11 @@ (%) :: Monoid n => Holey n b c -> Holey n b1 b -> Holey n b1 c f % g = f `bind` \a -> g `bind` \b -> now (a `mappend` b) +-- | Function compose two holeys. Will feed the result of one holey+-- into another.+(%.) :: Holey m r (a -> b) -> Holey a b c -> Holey m r c+(%.) (Holey a) (Holey b) = Holey (b . a)+ -- | Insert a constant monoidal value. now :: m -> Holey m r r now a = Holey ($ a)@@ -63,7 +75,3 @@ -- converted to the monoid type using the given conversion function. later :: (a -> m) -> Holey m r (a -> r) later f = Holey (. f)---- | Convert between underlying 'Monoid' types.-hmap :: (m -> n) -> Holey m r a -> Holey n r a-hmap g m = Holey (\k -> runHM m (k . g))
src/Formatting/Time.hs view
@@ -224,7 +224,8 @@ suffix = now (if fix && ts < 0 then " ago" else "") toInt ts base = abs (round (ts / base)) ranges =- [(0,int % " seconds",1)+ [(0,int % " milliseconds",0.001)+ ,(1,int % " seconds",1) ,(minute,fconst "a minute",0) ,(minute*2,int % " minutes",minute) ,(minute*30,fconst "half an hour",0)