[Haskell-beginners] Can someone help to unnest this "do" cascade

Martin Drautzburg Martin.Drautzburg at web.de
Wed Feb 6 22:31:05 CET 2013

Hello all,

here is a Code snipped from a Sound.ALSA.Sequencer example (much has been 
stripped and this code does not do anything). I just don't seem to get it. Can 
someone please walk me through it and possibly show ways to avoid the massive 

dtz = do
    SndSeq.withDefault SndSeq.Block $ \h -> do
      Client.setName (h :: SndSeq.T SndSeq.DuplexMode) "Haskell-Melody"
      Port.withSimple h "out"
        (Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite])
        (Port.types [Port.typeMidiGeneric, Port.typeApplication]) $ \p -> do
            Queue.with h $ \q -> do
              c <- Client.getId h
              let me = Addr.Cons c p
              conn <- parseDestArgs h me ["20:0"]
              Queue.control h q Event.QueueStart Nothing
              Queue.control h q (Event.QueueTempo (Event.Tempo 10000000)) Nothing
              return ()

More information about the Beginners mailing list