packages feed

papa-0.7.0: changelog.md

0.7.0

Breaking changes:

* `Papa` no longer exports `div`, `mod`, `divMod`, `quot`, `rem`, `quotRem`,
  `(^)`, `(/)`, `recip`, `(^^)` or `(%)`. `Prelude`'s, which throw, are in
  the new `Papa.Unsafe`, which `Papa` does not import, with `printf` and
  `hPrintf`. The total versions in `Papa` have names of their own and take a
  `NonZero` divisor: `divNonZero`, `modNonZero`, `divModNonZero`,
  `quotNonZero`, `remNonZero`, `quotRemNonZero`, `ratioNonZero`,
  `divideNonZero`, `recipNonZero`, `powNonZero`; and `pow` takes a `Word`
  exponent. `ratioNonZero` is `Integer -> NonZero Integer -> Rational`. Build a divisor once with `preview nonZero`, read it back with
  `the divisor`
* `maximum`, `minimum`, `maximumBy`, `minimumBy` are `Data.Foldable1`'s (any
  `Foldable1`, total, no `Maybe`); remove `maximum1`, `minimum1` and
  `Papa.Semigroupoids.Data.Semigroup.Foldable`
* `fromIntegral` is no longer exported by `Papa`: it is in
  `Papa.Unsafe.Numeric`. Use `intCast` (new; lossless conversions checked by
  the type checker) or `toIntegralSized`
* `Papa.Unsafe` is all of `Papa` with every partial function; the partial
  functions are also in `Papa.Unsafe.Numeric` and `Papa.Unsafe.Format`, which
  export only them
* `succ` needs only `Enum` (it works at `Integer`, `Natural`, `Double`)
* `fromLeft`, `fromRight` are generalised to the new names `left` and
  `right` (`LeftLike`, `RightLike`); `Papa.Base.Control.Arrow` exports
  `ArrowChoice`'s `left`, `right` as `leftA`, `rightA`
* `Papa.Base.Control.Monad.State`, `.Reader` and `.Error` are re-exported by
  `Papa`
* `Papa` exports the core of lens (`Papa.Lens.Core`) instead of all of
  `Control.Lens`; all of it, less its partial combinators, is in `Papa.Lens`
* Remove `Papa.Adjunctions.Renamed`, `Papa.Polytree.Renamed` and
  `Papa.Selective.Renamed`: `Papa.Adjunctions`, `Papa.Polytree` and
  `Papa.Selective` now import alongside `Papa`; `Papa.Associative.Renamed`
  hides only `null`
* `zero` (`Plus`) and `mfix` (`MonadFix`) are no longer exported: they throw
  at some instances; their classes still are
* Text first, and I/O errors are values: `putStr`, `putStrLn`, `print`,
  `getLine`, `getContents`, `readFile`, `writeFile`, `appendFile`,
  `interact`, `hPutStr`, `hPutStrLn`, `hGetLine`, `hGetContents` and `hPrint`
  are `Papa.Text.Data.Text.IO`'s: they read and write `Text` as UTF-8 whatever
  the locale, read strictly, and return `IOExcept` (`ExceptT IOFailure IO`)
  instead of throwing; invalid UTF-8 is a `DecodeFailed`. `lines`,
  `words`, `unlines` and `unwords` are `Text`'s (the `String` ones are in
  `Papa.Base.Data.List`)
* `openFile`, `withFile`, `hClose`, `hFlush`, `hIsEOF` and `hSetBuffering`
  return `IOExcept`. `hGetContents'`, `hGetChar`, `putChar` and `readLn` are
  no longer exported. Base's `System.IO`, String, lazy and throwing, is
  `Papa.Unsafe.IO`, imported qualified: `Papa.Unsafe` does not re-export it,
  since its names are `Papa`'s
* `catch`, `handle` and `try` never catch an asynchronous exception, even at
  `SomeException`; `bracket`, `bracket_`, `bracketOnError`, `finally` and
  `onException` release under `uninterruptibleMask_` (the semantics of
  safe-exceptions, implemented in `Papa.Base.Control.Exception`)
* `truncate`, `round`, `ceiling`, `floor`, `properFraction`, `toRational`
  and `realToFrac` are in `Papa.Unsafe.Numeric`: at `Double` and `Float` they
  return an arbitrary number for NaN and the infinities, and the rounding
  functions wrap where the result does not fit. `Papa` exports `RealFrac` and
  `Real` without these methods
* `modifyIORef` is not exported: use `modifyIORef'`
* `fromInteger` is not exported (numeric literals still work); the types
  `Natural` and `Ratio`, `minusNaturalMaybe` and `approxRational` are not
  exported either, and `Papa.Base.Numeric.Natural` is removed. All are in
  `Papa.Unsafe.Numeric`. `Papa` keeps `Rational`, `numerator` and
  `denominator`
* Pure `throw`, `error`, `errorWithoutStackTrace`, `undefined`, and lens's
  `throwing` and `throwing_`, are in the new `Papa.Unsafe.Exception`
* The `NonZero` division functions, the conversions and the order checks are
  rewritten for speed: they allocate no `Integer`, `pow` takes a `Word` path,
  `succ` allocates no list
* The vector, `Text` and `Char8` wrappers inline when partially applied
  (`foldl1' (+)`, `maximumBy compare`, `splitOn p`, `map f`): `foldl1' (+)`
  on a boxed vector goes from 242 µs to 98 µs, level with vector
* `Text` I/O's `hPutStr` and `hPutStrLn` write UTF-8 straight into the
  handle's buffer; both are 2–5 times as fast as `Data.Text.IO`
* `readMaybe`, `readEither` and `readIO` take `Text`, and `readEither`'s
  error is `Text`; `die` takes `Text` and writes it to `stderr` as UTF-8,
  exiting whether or not it could be written. Base's `String` versions are
  still in `Papa.Base`. `getArgs`, `getProgName` and `lookupEnv` still return
  `String`: an argument or a variable need not be UTF-8, and a file name
  must keep its bytes
* `Text` I/O's `hGetLine` finds the line in the handle's byte buffer and
  copies it straight into the text once it is checked as UTF-8, with no
  intermediate `ByteString`: 1.25–1.6 times as fast as before

Additions:

* `IOExcept` (`ExceptT IOFailure IO`), `exceptIO`, and `IOFailure`
  (`Papa.Base.System.IO.Except`): an `IOException` (`IOFailed`) or bytes that
  are not UTF-8 from a handle or file (`DecodeFailed`), with the prisms
  `_IOFailed`, `_DecodeFailed`, an `AsIOException` instance, and the classy
  `GetIOFailure`, `HasIOFailure`, `ReviewIOFailure`, `AsIOFailure`
* `except`, `liftEither`, `withExcept`, `mapExceptT`
* `approxRationalMaybe`
* The `Enum` documentation explains range syntax at `Float` and `Double`
* `MIGRATION.md`: a guide from `Prelude` to Papa
* `Papa.Directory.System.Directory`, re-exported by `Papa`: every action of
  `directory`, returning `IOExcept`. `withCurrentDirectory` takes an
  `IOExcept` action and restores the directory whether or not it fails. Not
  exported: `getDirectoryContents`, `isSymbolicLink`, `findFileWith`,
  `findFilesWith`
* `Papa.Filepath.System.FilePath`, re-exported by `Papa`: all of `filepath`,
  which is total; `(<.>)` is hidden, since it clashes with lens's (use
  `addExtension` or `-<.>`); `getSearchPath` returns `IOExcept`
* `Papa.Async.Control.Concurrent.Async`, re-exported by `Papa`: structured
  concurrency whose results are values (`waitCatch`, `waitExcept`, `poll`,
  the `…Catch` functions); `waitAnyCatch`, `waitAnyCatchSTM` and
  `waitAnyCatchCancel` take a `NonEmpty`; `concurrentlyExcept`, `raceExcept`
  for `ExceptT e IO`
* `Papa.Unsafe.Async`, re-exported by `Papa.Unsafe`: the `wait` functions,
  which rethrow, and `link`, `link2`, `linkOnly`, `link2Only`
* Depend on async (>= 2.2.5), directory and filepath
* `display :: Show a => a -> Text`
* `displayFixed`, `displayExponent :: RealFloat a => Word -> a -> Text`:
  a floating-point number with a number of decimal places (`showFFloat`,
  `showEFloat`, as `printf "%.2f"` shows it)
* `Papa.Base.Data.RealFloat`, re-exported by `Papa`: total floating-point
  division and rounding, whose results are floating-point numbers.
  `divideFloating` and `recipFloating` are `(/)` and `recip` at `RealFloat`
  only, where division by zero is an infinity or NaN; `floorFloating`,
  `ceilingFloating`, `truncateFloating` and `roundFloating` round to a whole
  number of the same type, as C's `floor` and the like do (NaN, the
  infinities and the sign of zero kept); `modFloating` is `Data.Fixed`'s
  `mod'`, NaN for a divisor of zero, where `mod'` throws
* `previewNonZero :: (Eq a, Num a) => a -> Maybe (NonZero a)`: `preview
  nonZero` whose type comes from where it is used, so a literal needs no
  annotation (`quotNonZero n <$> previewNonZero 100`), at any `Num`
* `truncateMaybe`, `roundMaybe`, `ceilingMaybe`, `floorMaybe`,
  `properFractionMaybe`, `toRationalMaybe`: `Nothing` for NaN, the
  infinities, and a result that does not fit; `floatToDouble`,
  `doubleToFloat` (NaN and the infinities kept, no `Rational`);
  `integralToFloating` (`Papa.Base.Data.RealFrac`)
* Exceptions: `mask`, `mask_`, `uninterruptibleMask`,
  `uninterruptibleMask_`, `getMaskingState`, `MaskingState`, `throwTo`,
  `SomeAsyncException`, `AsyncException`, `ArithException`, `ArrayException`,
  `ErrorCall`, `forkFinally`; `MonadThrow`, `MonadCatch`, `MonadMask` (the
  classes); lens's exception optics (`Papa.Lens.Control.Exception`:
  `catching`, `handling`, `trying`, `throwingM`, `_IOException`, ...) and
  `IOException` optics (`Papa.Lens.System.IO.Error`: `errorType`,
  `fileName`, `_NoSuchThing`, `_PermissionDenied`, ...; lens's `handle` is
  `errorHandle`)
* `nubOrd`, `nubOrdOn`, `nubInt`, `nubIntOn`
* text and bytestring, imported qualified, with total same-named
  replacements returning `Maybe` or `Either` for each function that throws:
  `Papa.Text.Data.Text`, `.Lazy`, `.Encoding`, `.Lazy.Encoding`, `.Read`,
  `.Lazy.Read` (range-checked: text's read `"300"` as `44` at `Word8`),
  `.Lazy.Builder`, `.Lazy.Builder.Int`, `.IO`; `Papa.Bytestring.Data.ByteString`,
  `.Lazy`, `.Char8`, `.Lazy.Char8`, `.Builder`, whose I/O returns `IOExcept`,
  whose `Char8` and `Builder` functions return `Nothing` rather than truncate
  a character, and which export no lazy I/O
* vector and unordered-containers, imported qualified:
  `Papa.Vector.Data.Vector`, `.Unboxed`, `.Storable`, `.Generic`, whose
  functions that throw for an index out of range, an empty vector, a
  negative length or mismatched lengths return `Maybe` under the same names
  in the same time; `(!)` and the `unsafe*` functions are not exported (use
  `ix`); `Papa.UnorderedContainers.Data.HashMap` (strict, without `(!)`),
  `.HashSet`, `Papa.Hashable.Data.Hashable`. `Papa` exports `Vector`,
  `HashMap`, `HashSet` and `Hashable`
* Depend on exceptions, hashable, primitive, unordered-containers and
  vector; `containers >= 0.6.0.1`, `text >= 2.0.2`

* `NonZero`, `nonZero` (the smart constructor, a prism at each numeric type
  of base), `divisor`, `validNonZero`, `lawNamesNonZero`, `InheritNonZero`,
  `inheritNonZero`, following the classy optics recipe
* `userError`, `Identity`, the equality constraint `~`, `showList`,
  `toNonEmpty`
* `the` (`Papa.Lens.Optic`), the classy optics reader
* `intCast`, `IntCast`, `IsIntSubType` (`Papa.Base.Data.IntCast`): integral
  conversions that cannot lose information, checked by the type checker,
  after the `int-cast` package
* `NonZero` instances `Eq1`, `Ord1`, `Show1`, `Foldable`, `Foldable1`
* `Text`, `pack`, `unpack`, `encodeUtf8`, `decodeUtf8'`; `ByteString`; the
  types `Map`, `Set`, `IntMap`, `IntSet`, `Seq`
* mtl: `StateT`, `State`, `ReaderT`, `Reader`, `ExceptT`, `Except`, their
  runners, `modify`, `modify'`, `gets`, `asks`, `withExceptT`
* Handles: `IOMode`, `BufferMode`, and (in `IOExcept`, above) `openFile`,
  `withFile`, `hClose`, `hIsEOF`, `hSetBuffering`
* Concurrency: `forkIO`, `ThreadId`, `myThreadId`, `killThread`,
  `threadDelay`, `MVar` and its functions; STM: `STM`, `TVar`, `atomically`,
  `newTVar`, `newTVarIO`, `readTVar`, `readTVarIO`, `writeTVar`,
  `modifyTVar'`, `retry`, `orElse`
* `time`: `UTCTime`, `NominalDiffTime`, `Day`, `getCurrentTime`,
  `diffUTCTime`, `addUTCTime`
* `die`, `coerce`, `Coercible`, `HasCallStack`, `swap`, `IsString`,
  `fromString`

Tests and tooling:

* The classy optics laws of `NonZero` (the prism laws at all 15 numeric
  types), and the laws of its new instances; the prism laws of `left` and
  `right`
* Fix: the `NonZero` division functions threw at `Natural` and divided wrongly
  by `maxBound` at the unsigned types (the `-1` check used `negate 1`)
* Fix: the lazy UTF-16 and UTF-32 decoders terminate (text's `...With`
  versions loop on input that ends partway through a code unit, and are not
  exported); the lazy `decimal` and `hexadecimal` reject input with no digit
* Every total function agrees with the partial one it replaces (`Nothing`
  exactly where it throws): the numeric functions at every numeric type of
  base, and the replacements of containers, text, bytestring and vector
* `test/Deny.hs`: the test suite does not compile if `Papa` exports any of
  73 partial, lossy or throwing names, or the types `Natural` and `Ratio`;
  `test/Totals.hs` pins the total type of
  each name `Papa` reuses
* `papa/exports`: the exports of every public module, checked in CI by
  `bin/exports.sh --check`
* The `inspection` test suite: the `NonZero` functions and conversions
  compile, at `Int`, `Word` and `Double`, to code with no class dictionary
  and no `Integer`
* `bench/Totality.hs`: each total function against the partial one it
  replaces
* `hGetLine` agrees with `Data.ByteString.Char8`'s `hGetLine` then
  `decodeUtf8'` on bytes that are not UTF-8 (overlong forms, surrogates,
  truncated sequences), at buffer sizes from 1 byte, and at any encoding
* `floorFloating`, `ceilingFloating`, `truncateFloating` and `roundFloating`
  agree with C's `floor`, `ceil`, `trunc` and `rint` at `Double` and
  `Float`, including at NaN, the infinities and `-0`; `modFloating` agrees
  with `Data.Fixed`'s `mod'` at `Rational`, rounded
* `examples/`: programs written for `Prelude` (`wind-correction`,
  `addgitignore`), ported to Papa; CI builds them with each change
* Properties of the files, directories and paths (agreement with
  `System.Directory`, and filepath's totality at every string) and of async
* Benchmarks of `Text` I/O against `Data.Text.IO`, and of the vector
  wrappers, partially applied and with their `Maybe` consumed
* GitLab CI runs every test suite, doctests included, on every GHC version

0.6.0

Breaking changes:

* Total replacements return `Maybe`: `(/)`, `recip`, `(^^)`, `exitWith`, `div` (new), `mod`, `divMod`, `quot`, `rem`, `quotRem`, `(^)`, `(%)`, `cycle`, `chr`, `succ` (new), `pred` (new), `stimes`, `stimesMonoid`, `stimesIdempotent`, `stimesIdempotentMonoid`, `mtimesDefault`, `readIO`
* `maximum`, `minimum` take a list and return a `Maybe`; `maximum1`, `minimum1` take a `NonEmpty`
* `concat`, `concatMap` are `Data.Foldable`'s again, not `Bind`'s; remove `Papa.Semigroupoids.Data.Functor.Bind`
* `partitionEithers` is generalised to any `Foldable`
* `Papa` no longer re-exports `Control.Comonad.Env` (its `ask`, `asks`, `local` clashed with `MonadReader`); import `Papa.Comonad.Control.Comonad.Env` qualified
* `Papa.Base.Control.Arrow` exports `Arrow`'s `first`, `second` as `firstA`, `secondA`, so that it imports alongside `Papa`
* The containers modules check the order of the input of `fromAscList`, `fromDescList`, `fromDistinctAscList`, `fromDistinctDescList`, their `With`/`WithKey` variants, `mapKeysMonotonic` and `mapMonotonic`, and return `Maybe` (containers' build a structure that breaks its invariant)
* `toEnum`, `fromEnum` are not exported (they throw outside the range of `Int`); `Enum` is exported for its constraint
* lens's partial combinators are no longer exported: `(^?!)`, `(^@?!)`, `foldr1Of`, `foldl1Of`, `foldr1Of'`, `foldl1Of'`, `singular`, `unsafeSingular`, `unsafePartsOf`, `unsafePartsOf'`, `iunsafePartsOf`, `iunsafePartsOf'`
* `fail` is no longer exported (it throws in `IO`); `MonadFail` still is
* The containers modules replace their partial functions with total ones of the same names: `Map`'s `(!)`, `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`, `elemAt`, `findIndex`, `deleteAt`, `updateAt`; `Set`'s `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`, `elemAt`, `findIndex`, `deleteAt`; `IntMap`'s `(!)`, `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`; `IntSet`'s `findMin`, `findMax`, `deleteFindMin`, `deleteFindMax`; `Seq`'s `index`, `replicate`, `replicateA`, `replicateM`, `iterateN`, `fromFunction`, `chunksOf`, `cycleTaking`, `scanl1`, `scanr1`
* `fromLeft`, `fromRight` are those of the relude replacements (same behaviour)
* Require GHC 9.6 or later (`base >= 4.18`); remove all CPP

Fixes:

* `(++)` is `infixr 5`, as in Prelude (it was `infixl 9`)
* `biconcat`, `biconcatMap` are defined once (importing `Papa` with `Papa.Bifunctors.Data.Bifoldable` was ambiguous)
* Export the constructors of `Sum`, `Product`, `Min`, `Max`, `First`, `Last`, `Dual`, `Endo`, `All`, `Any`, `WrappedMonoid`, `ZipList`, `WrappedMonad`, `WrappedArrow`
* `singleton`, `(!?)` are exported on every supported GHC, not only base 4.19 and later

Additions to `Papa`:

* `whenJust`, `whenJustM`
* `Handle`, `stdin`, `stdout`, `stderr`, `hPutStr`, `hPutStrLn`, `hFlush`; `Proxy`; `Compose`; `reads`; `MonadTrans`, `lift`; `(&&&)`
* `toIntegralSized` and `Bits` (the total `fromIntegral`)
* `seq`, `($!)`, `print`, `Bounded`, `Enum` (the class), `RealFrac`, `Word8`–`Word64`, `Natural`, `minusNaturalMaybe`, `unzip`, `singleton`, `(!?)`
* `catMaybes`, `mapMaybe`, `isJust`, `isNothing`, `listToMaybe`, `maybeToList`, `isLeft`, `isRight`
* `(>=>)`, `(<=<)`, `ap`, `liftM`, `liftM2`, `zipWithM`, `zipWithM_`, `MonadIO`, `liftIO`
* `Read` (the class), `readMaybe`, `readEither`
* `Exception`, `SomeException`, `IOException`, `throwIO`, `catch`, `handle`, `try`, `bracket`, `bracket_`, `finally`, `onException`, `evaluate`
* `IORef` and its functions; `getArgs`, `getProgName`, `getEnvironment`, `lookupEnv`; `ExitCode`, `exitWith`, `exitSuccess`, `exitFailure`

Tests and tooling:

* Hedgehog property suite for every function papa defines, with hedgehog-fn, lens laws for the `NonEmpty` lenses, and a check that every documented module imports alongside `Papa`
* Doctests, each with a Hedgehog property, for every function
* Criterion benchmarks
* GHC 9.6.7, 9.8.4, 9.10.3, 9.12.4, 9.14.1

0.5.0

* Remove `lens-indexed-plated` dependency to resolve GHC 9.12+ compatibility
* Add GHC 9.12.4 support
* Fix GHC 9.8+ compatibility by hiding `uncons`/`unsnoc` from `Papa.Base`
* Update CI to use `cabal build all` for multi-package project support
* Add `one >= 0.0.4` constraint for GHC 9.6+ MkSolo support
* Remove GHC 9.4.8 support (requires older dependency versions)

0.4.0

* Comprehensive type class coverage across ecosystem packages
* Full lens integration with indexed operations
* Safe alternatives to partial functions
* Performance optimizations with INLINE pragmas

0.3.1

* Remove doctests test target and setup

0.2.0

* Reorganisation of all `papa` packages.

0.1.0

* Reorganisation of all `papa` packages.

0.0.1

* Initial release