Skip to content

Commit

Permalink
Merge pull request #12 from bellroy/dependency-updates-2024-08
Browse files Browse the repository at this point in the history
Dependency updates 2024 08
  • Loading branch information
JackKelly-Bellroy authored Aug 22, 2024
2 parents e3f53f9 + dc44cdb commit 0c835e6
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 33 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.19.20240608
# version: 0.19.20240708
#
# REGENDATA ("0.19.20240608",["github","timeline.cabal"])
# REGENDATA ("0.19.20240708",["github","timeline.cabal"])
#
name: Haskell-CI
on:
Expand Down Expand Up @@ -38,9 +38,9 @@ jobs:
compilerVersion: 9.8.2
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.5
- compiler: ghc-9.6.6
compilerKind: ghc
compilerVersion: 9.6.5
compilerVersion: 9.6.6
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.8
Expand All @@ -65,10 +65,10 @@ jobs:
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.30.0/x86_64-linux-ghcup-0.1.30.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
env:
HCKIND: ${{ matrix.compilerKind }}
HCNAME: ${{ matrix.compiler }}
Expand All @@ -86,7 +86,7 @@ jobs:
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.vscode/
.direnv/
.envrc
.pre-commit-config.yaml
dist/
result
dist-newstyle
cabal.project.local
cabal.project.local
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
95 changes: 87 additions & 8 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
};

outputs = inputs: inputs.bellroy-nix-foss.lib.haskellProject {
src = ./.;
supportedCompilers = [ "ghc92" "ghc94" "ghc96" "ghc98" "ghc910" ];
defaultCompiler = "ghc96";
};
Expand Down
20 changes: 10 additions & 10 deletions src/Data/Timeline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module Data.Timeline
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)
Expand All @@ -59,7 +60,6 @@ import Data.Map.Merge.Strict qualified as Map
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
Expand Down Expand Up @@ -93,7 +93,7 @@ data Timeline t a = Timeline
}
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}

Expand All @@ -113,7 +113,7 @@ instance Ord t => Applicative (Timeline t) where
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
Expand All @@ -133,7 +133,7 @@ prettyTimeline Timeline {initialValue, values} =

-- | Extract a single value from the timeline
peek ::
Ord t =>
(Ord t) =>
Timeline t a ->
-- | the time to peek
t ->
Expand All @@ -150,10 +150,10 @@ data TimeRange t = TimeRange
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
Expand All @@ -165,9 +165,9 @@ instance Ord t => FunctorWithIndex (TimeRange t) (Timeline t) where
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

Expand Down Expand Up @@ -203,7 +203,7 @@ recordValue = value
-- | 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
Expand Down Expand Up @@ -297,7 +297,7 @@ unpackOverlapGroup (OverlapGroup r1 r2 records) = r1 : r2 : records
-- 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
Expand Down
23 changes: 16 additions & 7 deletions timeline.cabal
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -15,7 +15,14 @@ author: Bellroy Tech Team <[email protected]>
maintainer: Bellroy Tech Team <[email protected]>
category: Development
build-type: Simple
tested-with: GHC ==8.10.7 || ==9.2.8 || ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1
tested-with:
GHC ==8.10.7
|| ==9.2.8
|| ==9.4.8
|| ==9.6.6
|| ==9.8.2
|| ==9.10.1

extra-source-files:
CHANGELOG.md
README.md
Expand All @@ -29,9 +36,9 @@ common deps
build-depends:
, base >=4.14.3 && <4.21
, containers >=0.6.5 && <0.7.1
, hedgehog >=1.1 && <1.5
, hedgehog >=1.1 && <1.6
, indexed-traversable >=0.1.2 && <0.2
, text ^>=1.2.4.1 || >=2.0 && <2.2
, text ^>=1.2.4.1 || ^>=2.0 || ^>=2.1
, time >=1.9.3 && <1.15

library
Expand All @@ -44,10 +51,12 @@ library
default-language: Haskell2010
ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-unused-imports
build-depends:
, semigroupoids >=5.3.7 && <6.1
, 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
Expand All @@ -58,8 +67,8 @@ test-suite tests
build-tool-depends: tasty-discover:tasty-discover >=4.2 && <5.1
build-depends:
, bytestring >=0.10 && <0.13
, hashable ^>=1.4.2.0
, tasty >=1.4.3 && <1.6
, 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
Expand Down

0 comments on commit 0c835e6

Please sign in to comment.