I write a library with Java interfaces resembling Haskell type classes, and abstract classes implementing all "derivable" methods (eg Monad.join
can be written using >>=
and return
). This is my planned structure ([] means the interface doesn't exist yet):
Applicative <= Alternative <-,
Functor <= Pointed <= Applicative <= Monad <= MondPlus
Functor <= Copointed <= Comonad Monad <= [MonadFix]
Category <= Arrow <= ArrowChoice
Arrow <= [ArrowApply]
Arrow <= [ArrowLoop]
Arrow <= [ArrowZero] <= [ArrowPlus]
Bifunctor
You should make sure to consult the typeclassopedia .
Edward Kmett has been doing yeoman's work in trying to construct a rich, sane, hierarchy of core classes, starting with semigroups and moving forward. It's worth corresponding with him directly, but take a look at semigroupoids and the many related packages he's uploaded for some pointers:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.