FormationAI / dhall-bhat

Tasty meal of Dhall
66 stars 11 forks source link

extract* Functions #20

Closed FintanH closed 6 years ago

FintanH commented 6 years ago

Add functions to extract out subclasses for more safety.

For example if foo takes an Applicative, i.e. { map = ..., ap = ..., pure ... } and a Monad is in scope the current approach is to do monad.{ map, ap, pure }. This should be available as Monad/extractApplicative. It should also exist for other typeclasses:

jkachmar commented 6 years ago

With these functions in place, does it make sense to leave convenience functions in the package.dhall modules, or try to factor out all method usage in terms of extract*?

i.e. Applicative/Type would lose map = applicative.map and then usage would change from applicative.map to (extractFunctor f applicative).map

EDIT: Ah, nvm. I misinterpreted some of what this is