[Haskell-cafe] why OverloadedTuples extension is missing?

Viktor Dukhovni ietf-dane at dukhovni.org
Fri Jan 14 01:02:38 UTC 2022


On Thu, Jan 13, 2022 at 07:50:02PM -0500, Jeffrey Brown wrote:
> You can get very close -- specifically, to within two extra characters --
> to the brevity you're imagining without introducing any new extensions:
> 
>     data Foo = Foo Int Int
>       deriving (Show)
> 
>     f :: (Int, Int) -> Foo
>     f = uncurry Foo
> 
>     g :: Int -> Int -> Foo
>     g = Foo

    {-# LANGUAGE PatternSynonyms #-}

    pattern F :: Int -> Int -> Foo
    pattern F f s = Foo f s

Which abbreviates a frequently used constructor, and works in pattern
matches too.

    λ> case F 4 "2" of { F x y -> show x ++ y }
    "42"

But the original question is really about logical completeness of
overloading primitives, not about work-arounds, so bottom line I too
don't think that overloading tuples is justified, since this breaks
extensibility if constructor type signatures later become ambiguous, I
don't think the idea has sufficient merit.

-- 
    Viktor.


More information about the Haskell-Cafe mailing list