Skip to content

Latest commit

 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purescript Refined

A Purescript port of Refined.

Allows one to create types that restrain the values inside, and automatically generate validators for them.

For instance:

type DiceRoll = Refined (FromTo D1 D6) Int

invalidDiceRoll :: Either RefinedError DiceRoll
invalidDiceRoll = refine 8
-- invalidDiceRoll = Left (FromToError 1 6 8)

validDiceRoll :: Either RefinedError DiceRoll
validDiceRoll = refine 5
-- validDiceRoll = Right DiceRoll

diceRollToInt :: DiceRoll -> Int
diceRollToInt = unrefine

This package also contains EncodeJson and DecodeJson instances for Argonaut so that JSON data can be validated, and Arbitrary instances for use with QuickCheck.

Documentation can be found on Pursuit

About

Purescript refinement types with runtime checking

Topics

Resources

Stars

25 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages