Package

purescript-wrappable

Repository
cyrbon/purescript-wrappable
License
Apache-2.0
Uploaded by
cyrbon

Type classes to enable convenient wrapping and unwrapping.

Unlike purescript-newtype it provides separation between things that can be wraped and those that can be only unwraped. This provides extra safety in contexts where you want to hide the newtype constructor and only expose constuctor functions that validate data before wrapping it with a newtype.

In those scenarios, you want to be sure that data inside your newtype is always valid and that only your custom constructors will be used to create it, prohibiting invalid values from sneaking in.

If you only have a singular function that constructs your newtype then you can still provide a sensible wrap for Newtype by giving it your custom constructor that validates data before wrapping it. In that case, this package will not provide any extra value.

But if you have several alternative constructor functions that all generate the same newtype, then you can't supply a meaningful wrap function.

This allows you to enjoy the convenience of the unwrap without having to to specify wrap and vice versa.

Installation

bower install purescript-wrappable

Documentation

Module documentation is published on Pursuit.

Modules
Data.Wrappable
Dependencies