Are there any reasons against using ~ when matching one-constructor data types?

Dear Haskellers, b) A related suggestion would be the addition of an
irrefutable swap, (swap'?), defined as
"swap ~(a,b) = (b,a)", and its addition to Prelude for
the same reasons.
If I define a function that matches on a single-constructor data type, such as (,), is there any reason against using ~? Like f (a,b) = ... instead of f ~(a,b) = ... ? I've seen that not using ~ can lead to problems sometimes, but not the other way around. (Of course changing the semantics of existing functions such as `swap` is problematic, my question targets the problem in general.) Best regards, Petr Pudlak

* Petr Pudlák
If I define a function that matches on a single-constructor data type, such as (,), is there any reason against using ~? Like
f (a,b) = ...
instead of
f ~(a,b) = ...
? I've seen that not using ~ can lead to problems sometimes, but not the other way around.
(Of course changing the semantics of existing functions such as `swap` is problematic, my question targets the problem in general.)
The usual dangers of laziness apply. Consider, for example, the State monad. The difference between lazy and strict State is exactly the way of pattern matching on the tuple. Strict state monad allows you to keep your state evaluated. Lazy doesn't. Prelude Control.Monad.State.Strict> flip evalState () $ (put $! undefined) >> return () *** Exception: Prelude.undefined Prelude Control.Monad.State> flip evalState () $ (put $! undefined) >> return () () Roman
participants (2)
-
Petr Pudlák
-
Roman Cheplyaka