Description
Operators and Generics for Monads.
Description
Compose generic monadic function pipelines with %>>% and %>-% based on implementing the 'S7' generics fmap() and bind(). Methods are provided for the built-in list type and the maybe class from the 'maybe' package. The concepts are modelled directly after the Monad typeclass in Haskell, but adapted for idiomatic use in R.
README.md
monad
The monad package provides generics and generic operators for monadic classes. These are:
fmap()
,bind()
andjoin()
S7 generic functions.%>>%
and%>-%
pipe operators forfmap()
andbind()
respectively.
Implementations of the generics are provided for:
Implementing classes must provide fmap()
and either bind()
or join()
. Method implementations must satisfy the ?"functor-laws"
and ?"monad-laws"
.
The concepts are modelled directly after the Monad typeclass in the functional programming language Haskell. Operator names and calling conventions have been adapted to fit R.
Installation
Install the current release from CRAN:
install.packages("monad")
Or the development version from GitHub:
# install.packages("pak")
pak::pak("mikmart/monad")