[#159] Remove text-format dependency

Also support GHC-8.4.2
This commit is contained in:
Dmitry Kovanikov 2018-04-29 00:57:17 +03:00
parent f868329d34
commit e6f9d0ee2e
9 changed files with 20 additions and 33 deletions

View File

@ -24,8 +24,8 @@ matrix:
- ghc: 8.2.2
env: GHCVER='8.2.2' STACK_YAML="$HOME/build/serokell/universum/stack.yaml"
- ghc: 8.2.2
env: GHCVER='8.2.2' STACK_YAML="$HOME/build/serokell/universum/stack-nightly.yaml"
- ghc: 8.4.2
env: GHCVER='8.4.2' STACK_YAML="$HOME/build/serokell/universum/stack-$GHCVER.yaml"
- ghc: 8.2.2
env: GHCVER='8.2.2' STACK_YAML="$HOME/build/serokell/universum/stack-liquid.yaml"

View File

@ -1,3 +1,9 @@
1.2.0
=====
* [#159](https://github.com/serokell/universum/issues/159):
Remove `text-format` dependency.
1.1.1
=====

View File

@ -54,7 +54,7 @@ due to some historical reasons.
This is why we decided to use a better tool. Luckily, _Haskell_ provides us with the ability
to replace default `Prelude` with an alternative. All we had to do is to implement a
new basic set of defaults. There already were plenty of [preludes](https://guide.aelve.com/haskell/alternative-preludes-zr69k1hc),
new basic set of defaults. There already were plenty of [preludes](https://guide.aelve.com/haskell/alternative-preludes-zr69k1hc),
so we didn't plan to implement everything from scratch.
After some long, hot discussions, our team decided to base our custom prelude on
[`protolude`](https://github.com/sdiehl/protolude). If you're not familiar with it,
@ -145,8 +145,6 @@ Gotchas [↑](#structure-of-this-tutorial)
`OverloadedStrings` is enabled it happens because the compiler doesn't know what
type to infer for the string. Use `putTextLn` in this case.
* Since `show` doesn't come from `Show` anymore, you can't write `Show` instances easily.
Either use autoderived instances or
[`Buildable`](https://github.com/serokell/universum/blob/f2ccf8afd862e37ccd204c0ef9efde48a05c2d29/src/Universum.hs#L144).
* You can't call some `Foldable` methods over `Maybe` and some other types.
`Foldable` generalization is useful but
[potentially error-prone](https://www.reddit.com/r/haskell/comments/60r9hu/proposal_suggest_explicit_type_application_for/).
@ -217,7 +215,6 @@ Finally, we can move to part describing the new cool features we bring with `uni
* `ordNub` and `sortNub` are _O(n log n)_ versions of `nub` (which is quadratic)
and `hashNub` and `unstableNub` are almost _O(n)_ versions of `nub`.
* `(&)` reverse application. `x & f & g` instead of `g $ f $ x` is useful sometimes.
* `pretty` and `prettyL` for converting `Buildable` into `Text` (suggested be used instead of `show`).
* `whenM`, `unlessM`, `ifM`, `guardM` are available and do what you expect
them to do (e.g. `whenM (doesFileExist "foo")`).
* Very generalized version of `concatMapM`, too, is available and does what expected.

View File

@ -24,19 +24,15 @@ module Universum.String.Conversion
-- * Show and read functions
, readEither
, show
, pretty
, prettyL
) where
import Data.Bifunctor (first)
import Data.Either (Either)
import Data.Function (id, (.))
import Data.String (String)
import Data.Text.Buildable (build)
import Data.Text.Lazy.Builder (toLazyText)
import Universum.Functor ((<$>))
import Universum.String.Reexport (Buildable, ByteString, IsString, Read, Text, fromString, toStrict)
import Universum.String.Reexport (ByteString, IsString, Read, Text, fromString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as LB
@ -180,11 +176,3 @@ show x = fromString (Show.show x)
{-# SPECIALIZE show :: Show.Show a => a -> ByteString #-}
{-# SPECIALIZE show :: Show.Show a => a -> LByteString #-}
{-# SPECIALIZE show :: Show.Show a => a -> String #-}
-- | Functions to show pretty output for buildable data types.
pretty :: Buildable a => a -> Text
pretty = toStrict . prettyL
-- | Similar to 'pretty' but for 'LText'.
prettyL :: Buildable a => a -> LText
prettyL = toLazyText . build

View File

@ -13,15 +13,11 @@ module Universum.String.Reexport
-- * ByteString
, module Data.ByteString
-- * Buildable
, module Data.Text.Buildable
) where
import Data.ByteString (ByteString)
import Data.String (IsString (..))
import Data.Text (Text, lines, unlines, unwords, words)
import Data.Text.Buildable (Buildable)
import Data.Text.Encoding (decodeUtf8', decodeUtf8With)
import Data.Text.Encoding.Error (OnDecodeError, OnError, UnicodeException, lenientDecode,
strictDecode)

7
stack-8.4.2.yaml Normal file
View File

@ -0,0 +1,7 @@
resolver: nightly-2018-04-28
nix:
packages: [binutils, gmp]
extra-deps:
- tasty-hedgehog-0.2.0.0

View File

@ -1,7 +0,0 @@
resolver: nightly-2018-02-18
nix:
packages: [binutils, gmp]
extra-deps:
- tasty-hedgehog-0.1.0.2

View File

@ -1,4 +1,4 @@
resolver: lts-10.7
resolver: lts-11.5
nix:
shell-file: shell.nix

View File

@ -1,5 +1,5 @@
name: universum
version: 1.1.1
version: 1.2.0
synopsis: Custom prelude used in Serokell
description: See README.md file for more details.
homepage: https://github.com/serokell/universum
@ -16,6 +16,7 @@ bug-reports: https://github.com/serokell/universum/issues
tested-with: GHC == 7.10.3
, GHC == 8.0.2
, GHC == 8.2.2
, GHC == 8.4.2
extra-doc-files: CHANGES.md
, CONTRIBUTING.md
, README.md
@ -82,7 +83,6 @@ library
, safe-exceptions
, stm
, text
, text-format
, transformers
, type-operators
, unordered-containers