Unpacking tuples

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Unpacking tuples

Patrik Iselind
Hi,

If I have a function that produce tuples with three members and I want those members as parameters for a function that takes three parameters. How would I unpack that tuple? 

It seems that curry does the trick for tuples with two members.

How do I do this when there are more than two members?

Patrik

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Unpacking tuples

Frerich Raabe
On 2017-12-04 20:05, mrx wrote:
> Hi,
>
> If I have a function that produce tuples with three members and I want those
> members as parameters for a function that takes three parameters.
> How would I unpack that tuple?
>
> It seems that curry does the trick for tuples with two members.
>
> How do I do this when there are more than two members?

There are functions like 'curry3' (
http://hackage.haskell.org/package/utility-ht-0.0.14/docs/Data-Tuple-HT.html#v:curry3 
) but I think if you don't need this very often, it might be easiest to just
go for

   let (a,b,c) = f x in g a b c

--
Frerich Raabe - [hidden email]
www.froglogic.com - Multi-Platform GUI Testing
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Unpacking tuples

Patrik Iselind


Den 4 dec 2017 20:25 skrev "Frerich Raabe" <[hidden email]>:
On 2017-12-04 20:05, mrx wrote:
Hi,

If I have a function that produce tuples with three members and I want those members as parameters for a function that takes three parameters.
How would I unpack that tuple?

It seems that curry does the trick for tuples with two members.

How do I do this when there are more than two members?

There are functions like 'curry3' ( http://hackage.haskell.org/package/utility-ht-0.0.14/docs/Data-Tuple-HT.html#v:curry3 ) but I think if you don't need this very often, it might be easiest to just go for

  let (a,b,c) = f x in g a b c

Ok, so in general I would have to write the unpacking myself. Correct?

// Patrik

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners