Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use parameters in "IO(int, int)"

7 views
Skip to first unread message

一千瓦的刀狼

unread,
May 25, 2008, 3:47:35 AM5/25/08
to
Hi all,
I have got such a function like "Object => o -> IO(int, int)" from
existing API, and actually I needed is the parameters of "IO(int,
int)". How can I get these 2 parameters? just use a sentence like "x
<- fst(IO(int, int))"? Is it works? Or somebody will have a good idea
to help me? Thank you very much!

Dirk Thierbach

unread,
May 25, 2008, 6:04:07 AM5/25/08
to
?????? <knif...@gmail.com> wrote:

> I have got such a function like "Object => o -> IO(int, int)" from
> existing API, and actually I needed is the parameters of "IO(int,
> int)". How can I get these 2 parameters? just use a sentence like "x
> <- fst(IO(int, int))"? Is it works?

No, that doesn't work: Read up on Monads. Tutorials have just been
mentioned in a different thread.

> Or somebody will have a good idea to help me?

Try something like

> foo o = do
> (x1,x2) <- yourFunction o
> -- now do something with x1 and x2, eg add them:
> return (x1+x2)

But if you don't understand how to use the IO-Monad, you'll probably
quickly get stuck again.

- Dirk

一千瓦的刀狼

unread,
May 26, 2008, 9:14:47 AM5/26/08
to
On 5月25日, 下午6时04分, Dirk Thierbach <dthierb...@usenet.arcornews.de>
wrote:

Thank you very much! I will read the tutorial first

0 new messages