incipit-base 0.2.0.0 → 0.3.0.0
raw patch · 13 files changed
+128/−107 lines, 13 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Incipit.Base: (/) :: Fractional a => a -> a -> a
- Incipit.Base: recip :: Fractional a => a -> a
- Incipit.Debug: trs' :: Show b => HasCallStack => b -> a -> a
+ Incipit.Base: div :: Integral a => a -> a -> Maybe a
+ Incipit.Base: divMod :: Integral a => a -> a -> Maybe (a, a)
+ Incipit.Base: mod :: Integral a => a -> a -> Maybe a
+ Incipit.Base: quot :: Integral a => a -> a -> Maybe a
+ Incipit.Base: quotRem :: Integral a => a -> a -> Maybe (a, a)
+ Incipit.Base: rem :: Integral a => a -> a -> Maybe a
+ Incipit.Base: withFrozenCallStack :: HasCallStack => (HasCallStack => a) -> a
+ Incipit.Debug: trsi :: Show a => HasCallStack => a -> a
+ Incipit.Either: leftA :: Applicative m => (a -> m b) -> Either a b -> m b
+ Incipit.Fractional: (/) :: Eq a => Fractional a => a -> a -> Maybe a
+ Incipit.Fractional: recip :: Eq a => Fractional a => a -> Maybe a
+ Incipit.String: fromText :: IsString a => Text -> a
- Incipit.Debug: dbgs :: HasCallStack => Monad m => Show a => a -> m ()
+ Incipit.Debug: dbgs :: forall a m. HasCallStack => Monad m => Show a => a -> m ()
- Incipit.Debug: dbgs_ :: HasCallStack => Monad m => Show a => a -> m a
+ Incipit.Debug: dbgs_ :: forall a m. HasCallStack => Monad m => Show a => a -> m a
- Incipit.Debug: trs :: Show a => HasCallStack => a -> a
+ Incipit.Debug: trs :: forall b a. Show b => HasCallStack => b -> a -> a
- Incipit.Integral: safeOp :: Real a => (a -> a -> b) -> a -> a -> Maybe b
+ Incipit.Integral: safeOp :: Eq a => Num a => (a -> a -> b) -> a -> a -> Maybe b
Files
- changelog.md +0/−7
- incipit-base.cabal +12/−15
- lib/Incipit.hs +0/−25
- lib/Incipit/Base.hs +5/−3
- lib/Incipit/Debug.hs +14/−11
- lib/Incipit/Either.hs +11/−0
- lib/Incipit/Fixed.hs +4/−3
- lib/Incipit/Fractional.hs +31/−0
- lib/Incipit/Integral.hs +7/−2
- lib/Incipit/String.hs +19/−6
- lib/IncipitBase.hs +25/−0
- lib/Prelude.hs +0/−6
- readme.md +0/−29
− changelog.md
@@ -1,7 +0,0 @@-# Unreleased--# 0.2.0.0--* Add safe, `Maybe` returning, versions of the methods of `Integral`.-* Hide constructors of effect GADTs.-* Reexport `Data.Text.Lazy.Builder`.
incipit-base.cabal view
@@ -5,33 +5,30 @@ -- see: https://github.com/sol/hpack name: incipit-base-version: 0.2.0.0+version: 0.3.0.0 synopsis: A Prelude for Polysemy – Base Reexports-description: See <https://hackage.haskell.org/package/incipit-base/docs/Incipit-Prelude.html>+description: See https://hackage.haskell.org/package/incipit-base/docs/IncipitBase.html category: Prelude-homepage: https://github.com/tek/incipit#readme-bug-reports: https://github.com/tek/incipit/issues+homepage: https://github.com/tek/incipit-core#readme+bug-reports: https://github.com/tek/incipit-core/issues author: Torsten Schmits-maintainer: haskell@tryp.io+maintainer: hackage@tryp.io copyright: 2022 Torsten Schmits license: BSD-2-Clause-Patent license-file: LICENSE build-type: Simple-extra-source-files:- readme.md- changelog.md source-repository head type: git- location: https://github.com/tek/incipit+ location: https://github.com/tek/incipit-core library exposed-modules:- Incipit Incipit.Base Incipit.Debug Incipit.Either Incipit.Fixed+ Incipit.Fractional Incipit.Integral Incipit.Libraries Incipit.List@@ -39,7 +36,7 @@ Incipit.String Incipit.String.Conversion Incipit.String.Reexport- Prelude+ IncipitBase reexported-modules: Control.Concurrent.STM , Control.Concurrent.STM.TArray@@ -84,6 +81,7 @@ DeriveFoldable DeriveFunctor DeriveGeneric+ DeriveLift DeriveTraversable DerivingStrategies DerivingVia@@ -104,7 +102,6 @@ MultiParamTypeClasses MultiWayIf NamedFieldPuns- NoImplicitPrelude OverloadedStrings OverloadedLists PackageImports@@ -117,6 +114,7 @@ RankNTypes RecordWildCards RecursiveDo+ RoleAnnotations ScopedTypeVariables StandaloneDeriving TemplateHaskell@@ -129,7 +127,8 @@ UndecidableInstances UnicodeSyntax ViewPatterns- ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wmissing-deriving-strategies -Widentities+ NoImplicitPrelude+ ghc-options: -Wall -Wredundant-constraints -Wincomplete-uni-patterns -Wmissing-deriving-strategies -Widentities -Wunused-packages build-depends: base >=4.13 && <4.17 , bytestring@@ -137,6 +136,4 @@ , data-default >=0.2 , stm , text- if impl(ghc >= 8.10)- ghc-options: -Wunused-packages default-language: Haskell2010
− lib/Incipit.hs
@@ -1,25 +0,0 @@-{-# options_haddock prune #-}---- |This module is intended to be used by the packages [incipit-core](https://hackage.haskell.org/package/incipit-core)--- and [incipit](https://hackage.haskell.org/package/incipit), which are Preludes for packages using--- [Polysemy](https://hackage.haskell.org/package/polysemy).------ Aside from a few additional names from @base@, this module also exports the string system from--- [relude](https://hackage.haskell.org/package/relude), some tracing functions, and a small set of other combinators.-module Incipit (- module Incipit.Base,- module Incipit.Debug,- module Incipit.Either,- module Incipit.Libraries,- module Incipit.List,- module Incipit.Misc,- module Incipit.String,-) where--import Incipit.Base-import Incipit.Debug-import Incipit.Either-import Incipit.Libraries-import Incipit.List-import Incipit.Misc-import Incipit.String
lib/Incipit/Base.hs view
@@ -47,6 +47,7 @@ module GHC.Stack, module GHC.TypeLits, module Incipit.Fixed,+ module Incipit.Fractional, module Incipit.Integral, module Numeric.Natural, module System.IO,@@ -183,7 +184,7 @@ import GHC.Num (Integer, Num (..), subtract) import GHC.OverloadedLabels (IsLabel (..)) import GHC.Real (- Fractional (..),+ Fractional (fromRational), Integral (toInteger), Ratio, Rational,@@ -201,10 +202,11 @@ (^^), ) import GHC.Show (Show)-import GHC.Stack (HasCallStack)+import GHC.Stack (HasCallStack, withFrozenCallStack) import GHC.TypeLits hiding (ErrorMessage (Text)) import Numeric.Natural (Natural) import System.IO (FilePath, IO, print, putStr, putStrLn) import Incipit.Fixed-import Incipit.Integral+import Incipit.Fractional+import Incipit.Integral hiding (safeOp)
lib/Incipit/Debug.hs view
@@ -59,6 +59,7 @@ -- |Print a value with a 'Show' instance in an arbitrary 'Monad'. dbgs ::+ ∀ a m . HasCallStack => Monad m => Show a =>@@ -70,6 +71,7 @@ -- |Print a value with a 'Show' instance in an arbitrary 'Monad', returning the value. dbgs_ ::+ ∀ a m . HasCallStack => Monad m => Show a =>@@ -89,23 +91,24 @@ unsafePerformIO (a <$ debugPrint (srcLoc callStack) msg) {-# noinline tr #-} --- |Like 'Debug.Trace.traceShowId', but with 'Text' and with source location prefix.+-- |Like 'Debug.Trace.traceShow', but with source location prefix. trs ::- Show a =>+ ∀ b a .+ Show b => HasCallStack =>+ b -> a -> a-trs a =- unsafePerformIO (a <$ debugPrint (srcLoc callStack) (show a))+trs b a =+ unsafePerformIO (a <$ debugPrint (srcLoc callStack) (show b)) {-# noinline trs #-} --- |Like 'Debug.Trace.traceShow', but with 'Text' and with source location prefix.-trs' ::- Show b =>+-- |Like 'Debug.Trace.traceShowId', but with source location prefix.+trsi ::+ Show a => HasCallStack =>- b -> a -> a-trs' b a =- unsafePerformIO (a <$ debugPrint (srcLoc callStack) (show b))-{-# noinline trs' #-}+trsi a =+ unsafePerformIO (a <$ debugPrint (srcLoc callStack) (show a))+{-# noinline trsi #-}
lib/Incipit/Either.hs view
@@ -28,3 +28,14 @@ unify = either id id {-# inline unify #-}++-- |Run an applicative action on the 'Left' side of an 'Either' to unify the types.+leftA ::+ Applicative m =>+ (a -> m b) ->+ Either a b ->+ m b+leftA f = \case+ Right b -> pure b+ Left a -> f a+{-# inline leftA #-}
lib/Incipit/Fixed.hs view
@@ -1,3 +1,4 @@+-- |Safe overrides of the "Data.Fixed" division functions. module Incipit.Fixed where import qualified Data.Fixed as Fixed@@ -6,7 +7,7 @@ import Incipit.Integral (safeOp) --- | Generalisation of 'div' to any instance of 'Real'+-- | Generalisation of 'GHC.Real.div' to any instance of 'Real' div' :: Real a => Integral b =>@@ -16,7 +17,7 @@ div' = safeOp Fixed.div' --- | Generalisation of 'divMod' to any instance of 'Real'+-- | Generalisation of 'GHC.Real.divMod' to any instance of 'Real' divMod' :: Real a => Integral b =>@@ -26,7 +27,7 @@ divMod' = safeOp Fixed.divMod' --- | Generalisation of 'mod' to any instance of 'Real'+-- | Generalisation of 'GHC.Real.mod' to any instance of 'Real' mod' :: Real a => a ->
+ lib/Incipit/Fractional.hs view
@@ -0,0 +1,31 @@+-- |Safe overrides of the methods of class 'Fractional'.+module Incipit.Fractional where++import Data.Eq (Eq)+import Data.Maybe (Maybe (Just, Nothing))+import qualified GHC.Real as Real+import GHC.Real (Fractional)++import Incipit.Integral (safeOp)++-- | Fractional division.+(/) ::+ Eq a =>+ Fractional a =>+ a ->+ a ->+ Maybe a+(/) =+ safeOp (Real./)++-- | Reciprocal fraction.+recip ::+ Eq a =>+ Fractional a =>+ a ->+ Maybe a+recip = \case+ 0 ->+ Nothing+ a ->+ Just (Real.recip a)
lib/Incipit/Integral.hs view
@@ -1,11 +1,16 @@+-- |Safe overrides of the methods of class 'Integral'. module Incipit.Integral where +import Data.Eq (Eq) import Data.Maybe (Maybe (Just, Nothing))+import GHC.Num (Num) import qualified GHC.Real as Real-import GHC.Real (Integral, Real)+import GHC.Real (Integral) +-- |Helper for operations that return 'Nothing' if the second operand is @0@. safeOp ::- Real a =>+ Eq a =>+ Num a => (a -> a -> b) -> a -> a ->
lib/Incipit/String.hs view
@@ -37,13 +37,16 @@ -} -module Incipit.String- ( module Incipit.String.Reexport- -- $reexport- , module Incipit.String.Conversion- -- $conversion- ) where+module Incipit.String (+ module Incipit.String,+ module Incipit.String.Reexport,+ -- $reexport+ module Incipit.String.Conversion+ -- $conversion+) where +import Data.Function ((.))+ import Incipit.String.Conversion import Incipit.String.Reexport @@ -55,3 +58,13 @@ Conversion functions between 'Text', 'String', 'ByteString'. Also some read|show helper functions. -}++-- |Analog to 'fromString' for 'Text'.+-- Converts a 'Text' to any @a@ that is an instance of 'IsString'.+fromText ::+ IsString a =>+ Text ->+ a+fromText =+ fromString . toString+{-# inline fromText #-}
+ lib/IncipitBase.hs view
@@ -0,0 +1,25 @@+{-# options_haddock prune #-}++-- |This module is intended to be used by the packages [incipit-core](https://hackage.haskell.org/package/incipit-core)+-- and [incipit](https://hackage.haskell.org/package/incipit), which are Preludes for packages using+-- [Polysemy](https://hackage.haskell.org/package/polysemy).+--+-- Aside from a few additional names from @base@, this module also exports the string system from+-- [relude](https://hackage.haskell.org/package/relude), some tracing functions, and a small set of other combinators.+module IncipitBase (+ module Incipit.Base,+ module Incipit.Debug,+ module Incipit.Either,+ module Incipit.Libraries,+ module Incipit.List,+ module Incipit.Misc,+ module Incipit.String,+) where++import Incipit.Base+import Incipit.Debug+import Incipit.Either+import Incipit.Libraries+import Incipit.List+import Incipit.Misc+import Incipit.String
− lib/Prelude.hs
@@ -1,6 +0,0 @@--- |Exposing this module makes it possible to depend on the package without a mixin.-module Prelude (- module Incipit-) where--import Incipit
− readme.md
@@ -1,29 +0,0 @@-# About--This library is part of [incipit], a set of `Prelude` modules for the [Polysemy] ecosystem.-It contains the reexports from `base` that are inherited by the other two packages.--# Usage--`incipit-base` exports `Prelude`, so in order to use it you only have to hide `Prelude` from `base`:--For `hpack`:-```yaml-dependencies:- - name: base- version: '>= 4 && < 5'- mixin:- - hiding (Prelude)- - incipit-base >= 0.1.0.3-```--For `cabal`:-```cabal-build-depends:- base >=4 && <5, incipit-base >= 0.1.0.3-mixins:- base hiding (Prelude)-```--[incipit]: https://hackage.haskell.org/package/incipit-[Polysemy]: https://hackage.haskell.org/package/polysemy