Gabriella439 / Gabriella439/Haskell-Total-Library
Slightly generalize
- Dominant language
- Haskell
- Stars
- 33
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
We have
```haskell
at
:: ((() -> Identity b) -> s -> Identity t)
-> (i -> b)
-> (i -> s)
-> i
-> t
```
But `()` isn't really the only reasonable target type. We could have, for example,
```haskell
data Rec1 a b = Rec1 { _foo :: a, _bar :: b }
data Rec2 a b c = Rec2 { _baz :: Rec1 a b, _quux :: c }
```
There are two different reasonable ways to build a `Rec2` starting with `Rec2 () () ()`:
1. Use `baz . foo`, `baz . bar`, and `quux` to build from an `a`, a `b`, and a `c`.
2. Use `baz` and `quux` to build from a `Rec1 a b` and a `c`.
`at` currently only supports option 1. We can support option 2 using this type:
```haskell
atg
:: Full u => ((u -> Identity b) -> s -> Identity t)
-> (i -> b)
-> (i -> s)
-> i
-> t
```
Should the type of `at` be changed, or should a new function be added with the more general type?
----
The situation for `on` is similar, I believe. Suppose we have
```haskell
data Sum1 a b = A a | B b
data Sum2 a b c = AB (Sum1 a b) | C c
```
We currently support matching on `Sum2` using `_AB . _A`, `_AB . _B`, and `_C`, but not using `_AB` with `_C`. The target of `_AB` just can't be made `Void`; it needs to be made `Sum1 Void Void`.
We should be able to fix this the same way:
```haskell
ong
:: Empty v
=> ((a -> Either a v) -> s -> Either a r)
-> (a -> o)
-> (r -> o)
-> s
-> o
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.