Skip to content

tianjos/zeither

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zeither

Either Monad only for study purposes now.

Installation

Use the package manager pip to install zeither.

pip install zeither

Usage

from zeither import Either, left, right, is_either

either = Either(1)

assert either.map(lambda n: n + 1).value == 2

either = right('foo')

assert either.map(lambda prefix: prefix + 'bar').value == 'foobar'

either = left(ValueError('exception'))

assert either.left_map(lambda error: True if isinstance(error, ValueError) else False).value == True

either = right(1)

assert either.bind(lambda n: right(n + 1)).value == 2

either = left(1)

assert either.bind(lambda n: right(n + 1)).value == 1

assert is_either(either) == True

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

A either package (study purpose)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages