18 Feb 2013 20:02

## ~ operator ?

```Hi all,

I was creating "bigger" uncurries which I am simply extending from an existing uncurry I found some where, e.g.

uncurry4 :: (a -> b -> c -> d -> e) -> ((a, b, c, d) -> e)
uncurry4 f ~(a,b,c,d) = f a b c d

when I realized, what's the "~" for ?

I've only been able to find a partial explanation that it involves preserving laziness, or something,
maybe ?

I was hoping someone could enlighten me.

Thanks

Brian
```
18 Feb 2013 20:13

### Re: ~ operator ?

```On 18/02/13 19:02, briand <at> aracnet.com wrote:
> Hi all,
>
> I was creating "bigger" uncurries which I am simply extending from an existing uncurry I found some where, e.g.
>
> uncurry4 :: (a -> b -> c -> d -> e) -> ((a, b, c, d) -> e)
> uncurry4 f ~(a,b,c,d) = f a b c d
>
> when I realized, what's the "~" for ?
>
> I've only been able to find a partial explanation that it involves preserving laziness, or something,
maybe ?
>
> I was hoping someone could enlighten me.
>
> Thanks
>
> Brian
>
>
> _______________________________________________
>

[1] explains it in section 4.4 — ‘Lazy patterns’.

```

18 Feb 2013 23:01

### Re: ~ operator ?

```On Mon, 18 Feb 2013 19:13:13 +0000
Mateusz Kowalczyk <fuuzetsu <at> fuuzetsu.co.uk> wrote:

> On 18/02/13 19:02, briand <at> aracnet.com wrote:
> > Hi all,
> >
> > I was creating "bigger" uncurries which I am simply extending from an existing uncurry I found some
where, e.g.
> >
> > uncurry4 :: (a -> b -> c -> d -> e) -> ((a, b, c, d) -> e)
> > uncurry4 f ~(a,b,c,d) = f a b c d
> >
> > when I realized, what's the "~" for ?
> >
> > I've only been able to find a partial explanation that it involves preserving laziness, or something,
maybe ?
> >
> > I was hoping someone could enlighten me.
> >
> > Thanks
> >
> > Brian
> >
> >
> > _______________________________________________
> >
>
```

18 Feb 2013 20:19

### Re: ~ operator ?

The difference the ~ makes in this case is that `uncurry4 (\_ _ _ _ -> ()) undefined` evaluates to `()` instead of bottom. The ~ is called an irrefutable pattern, and it helps make code that pattern matches on constructors more lazy. This seems like a good explanation of the subject: http://en.wikibooks.org/wiki/Haskell/Laziness#Lazy_pattern_matching

On Mon, Feb 18, 2013 at 2:02 PM, wrote:
Hi all,

I was creating "bigger" uncurries which I am simply extending from an existing uncurry I found some where, e.g.

uncurry4 :: (a -> b -> c -> d -> e) -> ((a, b, c, d) -> e)
uncurry4 f ~(a,b,c,d) = f a b c d

when I realized, what's the "~" for ?

I've only been able to find a partial explanation that it involves preserving laziness, or something, maybe ?

I was hoping someone could enlighten me.

Thanks

Brian

_______________________________________________
```_______________________________________________