[Haskell-cafe] What pattern is this (Something.T -> IO a) in Sound.ALSA.Sequencer

2013-03-03 Thread Martin Drautzburg
Hello all, this was previously posted on Haskell Beginners, but only partially answered. In Sound.ALSA.Sequencer, there are a number of functions which together set up a midi environement (client, port, queue). They all have a type, where the last argument has a type like: (something.T -> IO a

Re: [Haskell-cafe] What pattern is this (Something.T -> IO a) in Sound.ALSA.Sequencer

2013-03-03 Thread Alexander Solla
On Sun, Mar 3, 2013 at 10:28 AM, Martin Drautzburg wrote: > Hello all, > > this was previously posted on Haskell Beginners, but only partially > answered. > > In Sound.ALSA.Sequencer, there are a number of functions which together > set up > a midi environement (client, port, queue). They all hav

Re: [Haskell-cafe] What pattern is this (Something.T -> IO a) in Sound.ALSA.Sequencer

2013-03-03 Thread Roman Cheplyaka
Hi Martin, These are called "continuations" or "callbacks". In this case, the term "callback" seems to fit better, since the result of continuation is an IO action. The common use case for callbacks is when you want to release some resources after the IO action completes. Let's look at the defini

Re: [Haskell-cafe] What pattern is this (Something.T -> IO a) in Sound.ALSA.Sequencer

2013-03-04 Thread Martin Drautzburg
On Sunday, 3. March 2013 21:11:21 Roman Cheplyaka wrote: > Admittedly, programming with callbacks is not very pleasant. So we have > an excellent alternative — the continuation monad transformer! > > This nested code > > something1 $ \x -> do > something2 $ \y -> do >

Re: [Haskell-cafe] What pattern is this (Something.T -> IO a) in Sound.ALSA.Sequencer

2013-03-05 Thread Roman Cheplyaka
* Martin Drautzburg [2013-03-04 21:21:30+0100] > On Sunday, 3. March 2013 21:11:21 Roman Cheplyaka wrote: > > > Admittedly, programming with callbacks is not very pleasant. So we have > > an excellent alternative — the continuation monad transformer! > > > > This nested code > > > > something