3 ms·
That's just one way to do it. Another might be collect :: Maybe (Maybe a) -> Either[Bool, a]
by tel 8y ago
That's just one way to do it. Another might be
collect :: Maybe (Maybe a) -> Either[Bool, a]
- JadeNB 8y agoBut you mentioned simplifying `Maybe (Maybe a)` to `Maybe a`, which your `collect` doesn't do (at least not directly). (Also, shouldn't `Either[Bool, a]` (which I don't know how to make sense of) be `Either Bool a`? Even with this signature, I'm not sure what the implementation would be, and Hoogle doesn't turn up any obviously correct results ( https://www.haskell.org/hoogle/?hoogle=collect https://www.haskell.org/hoogle/?hoogle=collect https://www.haskell.org/hoogle/?hoogle=Maybe+%28Maybe+a%29+-%3E+Either+Bool+a https://www.haskell.org/hoogle/?hoogle=Maybe+%28Maybe+a%29+-... ), but that's probably my fault.)
- dllthomas 8y agoI think the obvious implementation is `maybe (Left False) (maybe (Left True) Right)` If we have a value then we clearly have both layers. If we don't have a value then we need to distinguish Nothing from Just Nothing by way of the book.