danidiaz / dep-t

Dependency injection for records-of-functions.
http://hackage.haskell.org/package/dep-t
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Mention the possibility of using `NamedFieldPuns` to get the "methods" in a record. #21

Closed danidiaz closed 1 year ago

danidiaz commented 2 years ago

As opposed to using dep env + a field selector, or asCall + a field selector.

Maybe add some kind of helper typeclass? One with a deps method to facilitate extracting the methods of multiple records at a time?

Right now you can do (with NamedFieldPuns + ViewPatterns) something like

myFun (dep -> SomeDependency {someMethod}) = do ...

With the proposed deps, you could do something like

myFun (deps -> (SomeDependency {someMethod}, SomeOtherDependency {someOtherMethod)) = do ...

because there would be an instance of the helper typeclass for 2-tuples.

danidiaz commented 1 year ago

I've moved away from this.