Skip to content

Commit

Permalink
docs: Add "Refining first order types" section
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore committed Feb 13, 2024
1 parent 581f26b commit 7d83d1f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/_docs/reference/refinement.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ createUser("Iltotore", "abc123 ") //Left("Your password should be alphanumeric"

Note: Accumulative versions exist for [Cats](../modules/cats.md) and [ZIO](../modules/zio.md).

### Refining first order types

Iron provides utility methods to easily refine first order types (e.g container types like `List`, `Future`, `IO`...).

```scala
List(1, 2, 3).refineAllUnsafe[Positive] //List(1, 2, 3): List[Int :| Positive]
List(1, 2, -3).refineAllUnsafe[Positive] //IllegalArgumentException
```

Variants exist for `Option/Either`, `assume`, `...Further` as well as `RefinedTypeOps` constructors.

## Assuming constraints

Sometimes, you know that your value always passes (possibly at runtime) a constraint. For example:
Expand Down

0 comments on commit 7d83d1f

Please sign in to comment.