railroad 0.1.1.0 → 0.1.1.1
raw patch · 4 files changed
+19/−7 lines, 4 filesdep ~basedep ~effectfuldep ~mtlPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, effectful, mtl, validation
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- railroad.cabal +6/−6
- src/Railroad.hs +1/−1
- src/Railroad/MonadError.hs +6/−0
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for railroad +## 0.1.1.1 -- 2026-02-28+* Widen dependency bounds for better GHC compatibility:+ - `base` → `>= 4.17 && < 4.23` (supports GHC 9.4 through 9.14)+ - `effectful` → `>= 2.5 && < 2.7` (allows current 2.6.x series)+ - `mtl` lower bound relaxed to `>= 2.2`+ ## 0.1.1.0 -- 2026-02-26 * Add non unicode alias for `(?∅)` * Fix the fixity of `(??~)` to be inline with `(?~)`
railroad.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: railroad-version: 0.1.1.0+version: 0.1.1.1 license: BSD-3-Clause license-file: LICENSE author: Frederik Kallstrup Mastratisi@@ -21,10 +21,10 @@ common stuff ghc-options: -Wall build-depends:- base ^>=4.20.2.0,- effectful >= 2.5.1 && < 2.6,- mtl >= 2.3.1 && < 2.4,- validation >= 1.1.3 && < 1.2+ base >=4.17 && < 4.23,+ effectful >= 2.5 && < 2.7,+ mtl >= 2.2 && < 2.4,+ validation >= 1.1 && < 1.2 library import: stuff@@ -43,6 +43,6 @@ other-modules: RailroadSpec Railroad.MonadErrorSpec build-depends:- base ^>=4.20.2.0,+ base >=4.17 && < 4.23, hspec >= 2.11.14 && < 2.12, railroad
src/Railroad.hs view
@@ -87,7 +87,7 @@ action ?~ defaultVal = action ??~ (const defaultVal) --- TODO: Derive instances for it? Functor?+-- | @IsEmpty@ or @TooMany ta@ — structurally a @Maybe ta@ for cardinality failures data CardinalityError ta = IsEmpty | TooMany !ta -- | Catamorphism for CardinalityError
src/Railroad/MonadError.hs view
@@ -24,14 +24,17 @@ => (CErr f -> e) -> f -> m (CRes f) collapse toErr = either (throwError . toErr) pure . bifurcate +-- | Collapses a structure using an error mapper. (??) :: forall a m e. (MonadError e m, Bifurcate a) => m a -> (CErr a -> e) -> m (CRes a) action ?? toErr = action >>= collapse toErr +-- | Collapses a structure using an error mapper. (?) :: forall m e a. (MonadError e m, Bifurcate a) => m a -> e -> m (CRes a) action ? err = action ?? const err +-- | Collapses any value based on a predicate (?>) :: forall m e a. (MonadError e m) => m a -> (a -> Bool) -> (a -> e) -> m a (?>) action predicate toErr = do@@ -46,12 +49,14 @@ (?~) :: forall m a. (Bifurcate a, Monad m) => m a -> CRes a -> m (CRes a) action ?~ defaultVal = action ??~ (const defaultVal) +-- | Non-empty is sucess state. Returns the collection as-is. (?+) :: forall m e t a. (MonadError e m, Foldable t) => m (t a) -> e -> m (t a) (?+) action err = do xs <- action if null xs then throwError err else pure xs +-- | Single element is sucess state. Returns the single element (?!) :: forall m e t a. (MonadError e m, Foldable t) => m (t a) -> (CardinalityError (t a) -> e) -> m a (?!) action toErr = do@@ -61,6 +66,7 @@ [x] -> pure x _ -> throwError $ toErr $ TooMany xs +-- | Empty is success state. Returns Unit. (?∅) :: forall m e t a. (MonadError e m, Foldable t) => m (t a) -> (t a -> e) -> m () (?∅) action toErr = do