Open pelotom opened 8 years ago
Type.New lets you make a type which is isomorphic to, but distinct from another type:
Type.New
var ID = Type.New(String)
Type.Record lets you make a type with a single constructor which you don't have to name:
Type.Record
var Person = Type.Record({ id: ID, name: String, age: Number })
Use .from() to make instances of a Type.Record or Type.New:
.from()
var fred = Person.from({ id: ID.from('2ialp7b4lu'), // passing a simple string here would of course be an error name: 'Fred', age: 24 })
To extract the wrapped value of a newtype, use .value:
.value
console.log(fred.id.value) // prints '2ialp7b4lu'
These additions seem useful to me!
me too!
Type.New
lets you make a type which is isomorphic to, but distinct from another type:Type.Record
lets you make a type with a single constructor which you don't have to name:Use
.from()
to make instances of aType.Record
orType.New
:To extract the wrapped value of a newtype, use
.value
: