Skip to content

Commit

Permalink
[#246] Deprecate 'Relude.Extra.Validation' in favour of 'validation-s…
Browse files Browse the repository at this point in the history
…elective'

Resolves #246
  • Loading branch information
vrom911 committed May 12, 2020
1 parent 2eb6809 commit eb2cad5
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ The changelog is available [on GitHub][2].

* [#234](https://github.com/kowainik/relude/issues/234):
Reexport `scanl1`, `scanr1`, `scanl'` from `Data.List`.
* [#246](https://github.com/kowainik/relude/issues/246):
Deprecate `Relude.Extra.Validation` in favour of
[`validation-selective`](https://hackage.haskell.org/package/validation-selective)
__Migration rules:__
If you use "Relude.Extra.Validation" in you project you need to:

1. Add @validation-selective@ into the @build-depends@ section of your @.cabal@
file.
2. Change imports of "Relude.Extra.Validation" to "Validation":

```haskell
-- Was:
import Relude.Extra.Validation (Validation (..), ..)
-- Become:
import Validation (Validation (..), ..)
```

## 0.6.0.0 — Oct 30, 2019

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@ Finally, we can move to part describing the new cool features we bring with `rel

* `Foldable1` typeclass that contains generalized interface for folding
non-empty structures like `NonEmpty`.
* `Validation` data type as an alternative to `Either` when you want to combine
all errors.
* [`StaticMap` and `DynamicMap` type classes](src/Relude/Extra/Map.hs) as a
general interface for `Map`-like data structures.

Expand Down
5 changes: 5 additions & 0 deletions src/Relude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ every module in your package by modifying your "Prelude" file:
| __"Relude.Extra.Type"__ | Functions for inspecting and working with types. |
+------------------------------+-----------------------------------------------------------+
| __"Relude.Extra.Validation"__| 'Relude.Extra.Validation.Validation' data type. |
| | |
| | __⚠️ Warning ⚠️__ |
| | "Relude.Extra.Validation" is deprecated in favour of |
| | @validation-selective@: |
| | <https://hackage.haskell.org/package/validation-selective>|
+------------------------------+-----------------------------------------------------------+
| __"Relude.Unsafe"__ | Unsafe partial functions (produce 'error') for lists and |
| | 'Maybe'. |
Expand Down
4 changes: 4 additions & 0 deletions src/Relude/Extra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ Functions for inspecting and working with types.

{- $Validation
'Validation' data type.
__⚠️ Warning ⚠️__
"Relude.Extra.Validation" is deprecated in favour
of [validation-selective](https://hackage.haskell.org/package/validation-selective).
-}
31 changes: 31 additions & 0 deletions src/Relude/Extra/Validation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@ Maintainer: Kowainik <xrom.xkov@gmail.com>
Stability: Experimental
Portability: Portable
= Attention
__⚠️ Warning ⚠️__
This module is now deprecated @since 0.7.0.0.
The whole module will be removed in the upcoming release.
== Migration rules
The module is deprecated in favour of
[validation-selective](https://hackage.haskell.org/package/validation-selective).
The package has the identical functionality, so can be easily migrated to.
If you use "Relude.Extra.Validation" in you project you need to:
1. Add @validation-selective@ into the @build-depends@ section of your @.cabal@
file.
2. Change imports of "Relude.Extra.Validation" to "Validation":
@
-- Was:
import Relude.Extra.Validation (Validation (..), ..)
-- Become:
import Validation (Validation (..), ..)
@
= Description
'Validation' is a monoidal sibling to 'Either' but 'Validation' doesn't have a
'Monad' instance. 'Validation' allows to accumulate all errors instead of
short-circuiting on the first error so you can display all possible errors at
Expand Down Expand Up @@ -121,6 +149,7 @@ data Validation e a
#else
deriving (Eq, Ord, Show)
#endif
{-# DEPRECATED Validation "Use 'Validation' from 'validation-selective' instead"#-}

instance Functor (Validation e) where
fmap :: (a -> b) -> Validation e a -> Validation e b
Expand Down Expand Up @@ -354,6 +383,7 @@ validationToEither = \case
Failure e -> Left e
Success a -> Right a
{-# INLINE validationToEither #-}
{-# DEPRECATED validationToEither "Use 'validationToEither' from 'validation-selective' instead"#-}

{- | Transform an 'Either' into a 'Validation'.
Expand All @@ -368,6 +398,7 @@ eitherToValidation = \case
Left e -> Failure e
Right a -> Success a
{-# INLINE eitherToValidation #-}
{-# DEPRECATED eitherToValidation "Use 'eitherToValidation' from 'validation-selective' instead"#-}

----------------------------------------------------------------------------
-- Custom errors
Expand Down

0 comments on commit eb2cad5

Please sign in to comment.