[Haskell-cafe] Textbook example of instance Foldable ((,) a)

Viktor Dukhovni ietf-dane at dukhovni.org
Tue Nov 24 09:06:22 UTC 2020


On Tue, Nov 24, 2020 at 02:13:56AM -0500, amindfv--- via Haskell-Cafe wrote:

> Fwiw there is at least some strong user interest in this feature if
> anyone is thinking of working on it. I find myself checking on its
> progress pretty often, and would use it in our production codebase in
> a heartbeat.

Rather than waiting, it is perhaps more pragmatic to go with a custom
Prelude, which one can have now, even for versions of GHC/base, that
won't have the feature in question:

    {-# LANGUAGE NoImplicitPrelude #-}
    module Main (main) where
    import ListPrelude
    import qualified Data.Foldable as F

    main :: IO ()
    main = do
        let { one, two :: Int; one = 1; two = 2 }
        -- OK
        print $ length [one, two]
        print $ F.length (one, two)
        -- Type error
        -- print $ length (one, two)

-- 
    Viktor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ListPrelude.hs
Type: text/x-haskell
Size: 3695 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201124/1f6e3b04/attachment.hs>


More information about the Haskell-Cafe mailing list