Re: [livecode] Haskell state of affairs?

From: Mikael Johansson <mikael_at_johanssons.org>
Date: Thu, 19 Oct 2006 09:35:26 +0200 (CEST)

On Wed, 18 Oct 2006, alex wrote:
> On Thu, 2006-10-05 at 16:37 +0200, Julian Rohrhuber wrote:
>>> I'm a bit confused about how haskell's laziness and monads helps/impacts
>>> on livecoding...
>>
>> I'd be interested to hear about this, esp. about the difference to
>> sc, which is also stateless in its pattern/ugen graph definitions.
>
> Well I'm not the best person to answer although I'm also trying to learn
> supercollider properly. I can say though that Haskell somehow allows
> you to have state and imperative style programming through the power of
> monads. Monads are central to haskell, quite straightforward, yet
> rather difficult to fully grasp. So I really can't talk about them any
> more than this. But somehow they allow you to cleanly separate
> sequenced interactions with the messy world from the pure, far more
> reasonable functional part of your program, by assuming the monadic
> laws.
>
> Maybe Mikael can expand on and correct all the mistakes in the above...
>

Well, the description basically matches my own understanding of it as
well. I'm a relative Haskell newbie myself, but approaching the language
from the hardcore mathematical point of view -- viewing category theory as
the natural thing and Haskell as an expression of it.

>From the perspective of category theory, a monad is "just a thing
fulfilling these axioms", and you can (with some luck and the right
teacher) boil it down to that a monad is something you can "colour" your
objects (~ Haskell types) with. The funky part then is that whenever
you've coloured an object twice, there is a canonical way (part of the
Monad axioms) to remove one layer of colouring.

The first and most obvious instance -- from the category theoretical /
operad theoretical point of view of a monad is the List monad. Something
lives in the List monad if it actually lives in a tensor product of
objects of the category you work in -- so in Haskell language if it
actually IS a list of thingies. The associativity of the tensor product
gives the colour-reduction map -- and in Haskell language this translates
to a map taking [[a,v,c],[b,e],[e,f,a,d,y,g,h]] ->
[a,v,c,b,e,e,f,a,d,y,g,h]; flattening the list. Among operad theorists
(which is where I first encountered Monads...), the Monads grow funky
because you can use them to characterize "composition" much more smoothly:
there is an operad consisting of non-overlapping arrangements of circles
of various sizes within the unit circle. This can be expressed as a monad
of an appropriate sort. And as a result, you can include the monad chosen
in the formalism, and get a smoother way to handle the properties of the
thingies.

But this is all quite far from the livecoding aspects otoh...

> alex
>

-- 
Mikael Johansson                 | To see the world in a grain of sand
mikael_at_johanssons.org            |  And heaven in a wild flower
http://www.mikael.johanssons.org | To hold infinity in the palm of your hand
                                  |  And eternity for an hour
Received on Thu Oct 19 2006 - 09:21:50 BST

This archive was generated by hypermail 2.4.0 : Sun Aug 20 2023 - 16:02:23 BST