timeline 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+47/−36 lines, 3 filesdep +foldable1-classes-compatdep −semigroupoidsdep ~basedep ~containersdep ~hashablenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependencies added: foldable1-classes-compat
Dependencies removed: semigroupoids
Dependency ranges changed: base, containers, hashable, hedgehog, template-haskell, text, time, transformers
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- src/Data/Timeline.hs +10/−10
- timeline.cabal +32/−26
CHANGELOG.md view
@@ -1,4 +1,9 @@ # Changelog +## 0.1.1.0 -- 2024-08-22++- Depend on `foldable1-classes-compat` (when required) instead of+ `semigroupoids`.+ ## 0.1.0.0 - Open source the timeline library we use internally at Bellroy
src/Data/Timeline.hs view
@@ -50,6 +50,7 @@ where import Data.Foldable.WithIndex (FoldableWithIndex (..))+import Data.Foldable1 (fold1) import Data.Functor.Contravariant (Contravariant, contramap) import Data.Functor.WithIndex (FunctorWithIndex (..)) import Data.List (intercalate, sortOn)@@ -59,7 +60,6 @@ import Data.Map.Strict (Map) import Data.Map.Strict qualified as Map import Data.Maybe (mapMaybe, maybeToList)-import Data.Semigroup.Foldable.Class (fold1) import Data.Set (Set) import Data.Text (Text) import Data.Text qualified as T@@ -93,7 +93,7 @@ } deriving stock (Show, Eq, Generic, Functor, Foldable, Traversable) -instance Ord t => Applicative (Timeline t) where+instance (Ord t) => Applicative (Timeline t) where pure :: a -> Timeline t a pure a = Timeline {initialValue = a, values = mempty} @@ -113,7 +113,7 @@ funcs values -tshow :: Show a => a -> Text+tshow :: (Show a) => a -> Text tshow = T.pack . show -- | Pretty-print @'Timeline' a@. It's provided so that you can investigate the@@ -133,7 +133,7 @@ -- | Extract a single value from the timeline peek ::- Ord t =>+ (Ord t) => Timeline t a -> -- | the time to peek t ->@@ -150,10 +150,10 @@ deriving stock (Show, Eq, Ord, Generic) -- | If all time in 'TimeRange' is less than the given time-isTimeAfterRange :: Ord t => t -> TimeRange t -> Bool+isTimeAfterRange :: (Ord t) => t -> TimeRange t -> Bool isTimeAfterRange t TimeRange {to} = maybe False (t >=) to -instance Ord t => FunctorWithIndex (TimeRange t) (Timeline t) where+instance (Ord t) => FunctorWithIndex (TimeRange t) (Timeline t) where imap :: (TimeRange t -> a -> b) -> Timeline t a -> Timeline t b imap f Timeline {..} = Timeline@@ -165,9 +165,9 @@ where initialRange = TimeRange Nothing $ fst <$> Map.lookupMin values -instance Ord t => FoldableWithIndex (TimeRange t) (Timeline t)+instance (Ord t) => FoldableWithIndex (TimeRange t) (Timeline t) -instance Ord t => TraversableWithIndex (TimeRange t) (Timeline t) where+instance (Ord t) => TraversableWithIndex (TimeRange t) (Timeline t) where itraverse :: (Applicative f) => (TimeRange t -> a -> f b) -> Timeline t a -> f (Timeline t b) itraverse f = sequenceA . imap f @@ -203,7 +203,7 @@ -- | A smart constructor for @'Record' a@. -- Returns 'Nothing' if @effectiveTo@ is not greater than @effectiveFrom@ makeRecord ::- Ord t =>+ (Ord t) => -- | effective from t -> -- | optional effective to@@ -297,7 +297,7 @@ -- by wrapping the result in 'Maybe', so the only possible error is 'Overlaps'. -- The 'Traversable' instance of @'Timeline' a@ can be used to convert -- @'Timeline' ('Maybe' a)@ to @'Maybe' ('Timeline' a)@-fromRecords :: forall t a. Ord t => [Record t a] -> Either (Overlaps t a) (Timeline t (Maybe a))+fromRecords :: forall t a. (Ord t) => [Record t a] -> Either (Overlaps t a) (Timeline t (Maybe a)) fromRecords records = maybe (Right timeline) Left overlaps where
timeline.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: timeline-version: 0.1.0.0+version: 0.1.1.0 synopsis: Data type representing a piecewise-constant function over time @@ -15,27 +15,32 @@ maintainer: Bellroy Tech Team <haskell@bellroy.com> category: Development build-type: Simple-tested-with: GHC ==8.10.7 || ==9.2.6 || ==9.4.4-extra-source-files:+tested-with:+ GHC ==8.10.7+ || ==9.2.8+ || ==9.4.8+ || ==9.6.6+ || ==9.8.2+ || ==9.10.1++extra-doc-files: CHANGELOG.md README.md- test/golden/*.txt +extra-source-files: test/golden/*.txt+ source-repository head type: git location: https://github.com/bellroy/timeline.git common deps build-depends:- , base >=4.14.3 && <4.18- , containers >=0.6.5 && <0.7- , hedgehog >=1.1 && <1.3- , indexed-traversable >=0.1.2 && <0.2- , semigroupoids >=5.3.7 && <5.4- , template-haskell >=2.16.0 && <2.20- , text >=1.2.4.1 && <2.1- , th-compat >=0.1.4 && <0.2- , time >=1.9.3 && <1.13+ , base >=4.14.3 && <4.21+ , containers >=0.6.5 && <0.7.1+ , hedgehog >=1.1 && <1.6+ , indexed-traversable >=0.1.2 && <0.2+ , text ^>=1.2.4.1 || ^>=2.0 || ^>=2.1+ , time >=1.9.3 && <1.15 library import: deps@@ -46,8 +51,15 @@ default-language: Haskell2010 ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-unused-imports+ build-depends:+ , template-haskell >=2.16.0 && <2.23+ , th-compat >=0.1.4 && <0.2 + if impl(ghc <9.6)+ build-depends: foldable1-classes-compat ^>=0.1+ test-suite tests+ import: deps type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Main.hs@@ -55,17 +67,11 @@ default-language: Haskell2010 build-tool-depends: tasty-discover:tasty-discover >=4.2 && <5.1 build-depends:- , base >=4.14.3 && <4.18- , bytestring >=0.10 && <0.12- , containers >=0.6.5 && <0.7- , hashable ^>=1.4.2.0- , hedgehog >=1.1 && <1.3- , indexed-traversable ^>=0.1.2- , tasty ^>=1.4.3- , tasty-golden ^>=2.3.5- , tasty-hedgehog >=1.2.0.0- , tasty-hunit ^>=0.10.0.3- , text >=1.2.4.1 && <2.1- , time >=1.9.3 && <1.13+ , bytestring >=0.10 && <0.13+ , hashable ^>=1.4.2.0 || ^>=1.5+ , tasty >=1.4.3 && <1.6+ , tasty-golden ^>=2.3.5+ , tasty-hedgehog >=1.2.0.0+ , tasty-hunit ^>=0.10.0.3 , timeline- , transformers ^>=0.5.6.2+ , transformers >=0.5.6.2 && <0.6.2.0