Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 625 Bytes

adapters.md

File metadata and controls

25 lines (20 loc) · 625 Bytes

Adapters

This is the list of currently tested adapters for popular monad libraries that define a Maybe type:

true-myth (default)

chai.use( maybeChai() )

// Which is the same as this:
chai.use( maybeChai( {
    match: ( maybe, cases ) => maybe.match( cases ),
    isMaybe: obj => obj && typeof obj.match === 'function',
} ) )

Sanctuary

import S from 'sanctuary'
import type from 'sanctuary-type-identifiers'

chai.use( maybeChai( {
    match: (maybe, cases) => S.maybe_ (cases.Nothing) (cases.Just) (maybe),
    isMaybe: obj => type.parse( type( obj ) ).name === 'Maybe',
} ) )