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

`Bare` should not recurse inside `Identity` and `Const` #26

Closed danidiaz closed 2 years ago

danidiaz commented 2 years ago

The Bare type family removes nested layers of Compose newtypes so that values are easier to create. It also removes any Identity and Const newtypes it encounters, and recurses inside them.

However, recursing inside Identity and Const causes problems. It makes difficult to write fromBare-using functions polymorphic on the returned component. Bare gets stuck on the component's type variable and the functions do not compile:

image

This leads to unnecessary code duplication. If we stopped at Identity, Bare would never touch the type variable and wouldn't get stuck.

Strictly speaking, this is a breaking change, but the cases in which it breaks are very unlikely in practice: when using Identity or Const in the middle of a sequence of phases. Typically, these two applicatives will be used as the colophon of the sequence of phases.

danidiaz commented 2 years ago

Added in 82d8750e15760bfa71bd56fd38ad8022ebbdd99f.