[Haskell-cafe] Is it possible to nest this kind of "continuation" (a -> b -> r)

Tom Ellis tom-lists-haskell-cafe-2023 at jaguarpaw.co.uk
Fri Apr 19 16:59:59 UTC 2024


On Fri, Apr 19, 2024 at 06:29:23PM +0200, PICCA Frederic-Emmanuel wrote:
> nest ∷ [(a → r) → r] → ([a] → r) → r 
> nest xs = runCont (Prelude.mapM	cont xs)
> 
> nest2 ∷ [(a → b → r) → r] → ([a] → [b] → r) → r 
> nest2 xs = ...
> 
> nest3 :: ...
> 
> Do you think that there is a generic way to write all these nestX methodes.

I doubt it.  There's not even a generic way of writing out the
non-CPSed versions

    nest2 :: [(a, b)] -> ([a], [b])
    nest3 :: [(a, b, c)] -> ([a], [b], [c])

Instead we just have individually-named unzip functions:

https://www.stackage.org/haddock/lts-22.17/base-4.18.2.0/Prelude.html#v:unzip
https://www.stackage.org/haddock/lts-22.17/base-4.18.2.0/Prelude.html#v:unzip3

Tom


More information about the Haskell-Cafe mailing list