All Projects → kowainik → validation-selective

kowainik / validation-selective

Licence: MPL-2.0 license
💂‍♂️ Lightweight pure validation based on Applicative and Selective functors

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to validation-selective

kudojs
A utility library to write code in functional programming style in Javascript
Stars: ✭ 22 (-63.93%)
Mutual labels:  applicative
functional-structures-refactoring-kata
Starting code and proposed solution for Functional Structures Refactoring Kata
Stars: ✭ 31 (-49.18%)
Mutual labels:  applicative
Language Ext
C# functional language extensions - a base class library for functional programming
Stars: ✭ 3,964 (+6398.36%)
Mutual labels:  applicative
Swiftz-Validation
A data structure for validations. It implements the applicative functor interface
Stars: ✭ 15 (-75.41%)
Mutual labels:  applicative
free-arrow
Implementation of the Free Arrow in Scala and other helpful tools for working with Arrows
Stars: ✭ 14 (-77.05%)
Mutual labels:  applicative
play2scalaz
Scalaz typeclasses <~> Playframework2 typeclasses
Stars: ✭ 14 (-77.05%)
Mutual labels:  applicative
cpsfy
🚀 Tiny goodies for Continuation-Passing-Style functions, fully tested
Stars: ✭ 58 (-4.92%)
Mutual labels:  applicative
zeroapply
zero cost Apply/Applicative syntax
Stars: ✭ 12 (-80.33%)
Mutual labels:  applicative
owlet
Typed Spreadsheet UI library for ScalaJS
Stars: ✭ 40 (-34.43%)
Mutual labels:  applicative
elixir-control
An exploratory look into functors, applicatives, and monads for Elixir
Stars: ✭ 21 (-65.57%)
Mutual labels:  applicative
DeleteMessagesRoBot
Watch https://youtu.be/RHQ-RP4_pKY, or Read the Code to know how to use this Telegram Bot.
Stars: ✭ 59 (-3.28%)
Mutual labels:  selective
NIPS-Global-Paper-Implementation-Challenge
Selective Classification For Deep Neural Networks.
Stars: ✭ 11 (-81.97%)
Mutual labels:  selective
CatsCheatSheet
This project is to contain a listing of common theorems in elementary category theory.
Stars: ✭ 61 (+0%)
Mutual labels:  functors
declarative-form-generator
A simple react form generator using functional programming concepts
Stars: ✭ 14 (-77.05%)
Mutual labels:  functors
konad
Monads composition API that just works. For OOP developers
Stars: ✭ 62 (+1.64%)
Mutual labels:  functors
specifica
Basic TLA+ related Haskell libraries (parser, evaluator, pretty-printer)
Stars: ✭ 19 (-68.85%)
Mutual labels:  haskell-libraries

validation-selective

Logo GitHub CI

Hackage MPL-2.0 license

Lightweight pure data validation based on Applicative and Selective functors.

validation-selective is built around the following data type:

data Validation e a
    = Failure e
    | Success a

This data type is similar to Either but allows accumulating all errors instead of short-circuiting on the first one.

For more examples and library tutorial, refer to Haddock:

Comparison with other packages

validation-selective is not the only package that provides such Validation data type. However, unlike other packages, it has some noticeable advantages:

  • Lightweight. validation-selective depends only on base and selective (which is tiny) Haskell libraries which make this package fast to build. So adding validation capabilities to your library or application doesn't contribute much to your dependency footprint.
  • Selective instance. validation-selective is the only package that provides Selective instance for Validation which allows using Monad-like branching behaviour but without implementing wrong Monad instance.
  • More algebraic instances. validation-selective also provides the Alternative instance and a more general Semigroup instance.
  • Best-in-class documentation. Official Haddock documentation contains mini-tutorial, usage example, per-component comparison with Either, the motivation behind each instance and the interface in general along with examples for each instance and function.

The below section provides per-package comparison with the most popular validation packages in the Haskell ecosystem:

  • either: Validation implementation by Edward Kmett. This package is more heavyweight, since it depends on more Haskell libraries like profunctors, bifunctors, semigroupoids. But it also provides prisms for Validation and some combinators for Either.
  • validation: Validation from Queensland Functional Programming Lab. Depends on lens, which makes it even heavier but also have richer interface compared to the either package.

How to use

validation-selective is compatible with the latest GHC compiler versions starting from 8.4.4.

In order to start using validation-selective in your project, you will need to set it up with the three easy steps:

  1. Add the dependency on validation-selective in your project's .cabal file. For this, you should modify the build-depends section by adding the name of this library. After the adjustment, this section could look like this:

    build-depends: base ^>= 4.14
                 , validation-selective ^>= 0.0
  2. In the module where you wish to implement pure data validation, you should add the import:

    import Validation (Validation (..))
  3. Now you can use the types and functions from the library:

    main :: IO ()
    main = print [Failure "wrong", Success 42]

Usage with Stack

If validation-selective is not available on your current Stackage resolver yet, fear not! You can still use it from Hackage by adding the following to the extra-deps section of your stack.yaml file:

extra-deps:
  - validation-selective-CURRENT_VERSION
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].