# Data.Refined

- Package
- purescript-refined
- Repository
- danieljharvey/purescript-refined

### #Refined Source

`newtype Refined p x`

#### Constructors

`Refined x`

#### Instances

`(Eq x) => Eq (Refined p x)`

`(Show x) => Show (Refined p x)`

`(Ord x) => Ord (Refined p x)`

`Generic (Refined p x) _`

`(DecodeJson x, Show x, Predicate p x) => DecodeJson (Refined p x)`

`(EncodeJson x) => EncodeJson (Refined p x)`

for encoding we just want to strip away the outside layer and use whatever is inside

`(Arbitrary a, Predicate p a) => Arbitrary (Refined p a)`

create an Arbitrary instance by randomly throwing values against the wall until something sticks

### #unsafeRefine Source

`unsafeRefine :: forall x p. Predicate p x => x -> (Refined p x)`

## Re-exports from **Data.**Refined.Error

### #RefinedError Source

`data RefinedError a`

#### Constructors

`AndError (These (RefinedError a) (RefinedError a))`

`OrError (RefinedError a) (RefinedError a)`

`SizeEqualToError Int a`

`SizeGreaterThanError Int a`

`SizeLessThanError Int a`

`NotError`

`LessThanError Int a`

`GreaterThanError Int a`

`FromError Int a`

`ToError Int a`

`FromToError Int Int a`

`EqualToError Int a`

`NotEqualToError Int a`

#### Instances

`(Eq a) => Eq (RefinedError a)`

`(Show a) => Show (RefinedError a)`

## Re-exports from **Data.**Refined.Internal

## Re-exports from **Data.**Refined.Predicate

### #SizeLessThan Source

`data SizeLessThan a`

A 'Predicate' ensuring that the length of a foldable is less than a given int

#### Instances

`(Predicate a x, Foldable t, Nat n) => Predicate (SizeLessThan n) (t a)`

### #SizeGreaterThan Source

`data SizeGreaterThan a`

A 'Predicate' ensuring that the length of a foldable is greater than a given int

#### Instances

`(Predicate a x, Foldable t, Nat n) => Predicate (SizeGreaterThan n) (t a)`

### #SizeEqualTo Source

`data SizeEqualTo a`

A 'Predicate' ensuring that the length of a foldable is equal to a given int

#### Instances

`(Predicate a x, Foldable t, Nat n) => Predicate (SizeEqualTo n) (t a)`

### #Positive Source

`type Positive = GreaterThan D0`

A 'Predicate' ensuring that the value is greater than zero.

### #NotEqualTo Source

`data NotEqualTo n`

A 'Predicate' ensuring that the value is not equal to a given int

#### Instances

`(Nat n, Eq x, Ring x) => Predicate (NotEqualTo n) x`

### #NonZero Source

`type NonZero = NotEqualTo D0`

A 'Predicate' ensuring that the value is not equal to zero.

### #NonNegative Source

`type NonNegative = From D0`

A 'Predicate' ensuring that the value is greater than or equal to zero.

### #NonEmpty Source

`type NonEmpty = SizeGreaterThan D0`

A 'Predicate' ensuring that the 'Foldable' is non-empty.

### #GreaterThan Source

`data GreaterThan n`

A 'Predicate' ensuring that the value is greater than a given int

#### Instances

`(Nat n, Ord x, Ring x) => Predicate (GreaterThan n) x`

### #Predicate Source

`class Predicate p x where`

#### Members

`validate :: p -> x -> Either (RefinedError x) x`

#### Instances

`Predicate IdPred x`

`(Predicate l x, Predicate r x) => Predicate (And l r) x`

`(Predicate l x, Predicate r x) => Predicate (Or l r) x`

`(Predicate a x, Foldable t, Nat n) => Predicate (SizeEqualTo n) (t a)`

`(Predicate a x, Foldable t, Nat n) => Predicate (SizeGreaterThan n) (t a)`

`(Predicate a x, Foldable t, Nat n) => Predicate (SizeLessThan n) (t a)`

`(Predicate a x) => Predicate (Not a) x`

`(Nat n, Ord x, Ring x) => Predicate (LessThan n) x`

`(Nat n, Ord x, Ring x) => Predicate (GreaterThan n) x`

`(Nat n, Ord x, Ring x) => Predicate (From n) x`

`(Nat n, Ord x, Ring x) => Predicate (To n) x`

`(Nat n, Nat m, Ord x, Ring x) => Predicate (FromTo m n) x`

`(Nat n, Eq x, Ring x) => Predicate (EqualTo n) x`

`(Nat n, Eq x, Ring x) => Predicate (NotEqualTo n) x`

for decoding we first decode the thing inside, then run our predicate on it