[Haskell-cafe] tuple and pattern synonym

Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=) kazu at iij.ad.jp
Mon May 18 03:56:47 UTC 2020


Hi,

I have a question about PatternSynonyms. Suppose we have:

   data Foo = Foo Int Int

I would like to define a pattern as follows:

   pattern P :: (Int,Int) -> Foo
   pattern P (x,y)  = Foo x y

But this results in "parse error on input ‘(’". Are there any ways to
use tuple in the left side hand of patterns?

This is important to maintain backward compatibility for the "network"
library.

If there is no way, I will define Foo as:

   data Foo = Foo (Int,Int) -- awkward

and define P as:

   pattern P :: (Int,Int) -> Foo
   pattern P xy = Foo xy

Regards,

--Kazu


More information about the Haskell-Cafe mailing list