Created
September 13, 2012 07:55
-
-
Save Ahnfelt/3712717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Sound | |
= Silence | |
| Audio AudioData | |
| Volume Double Sound | |
| Sequence Sound Sound | |
data SoundM a = SoundM Sound a | |
instance Monad SoundM where | |
return a = SoundM Silence a | |
SoundM s a >>= f = let SoundM s' a' = f a in SoundM (Sequence s s') a' | |
play :: SoundM a -> IO a | |
play (SoundM s a) = do | |
p <- setup | |
... | |
close p | |
return a | |
sound :: Sound -> SoundM () | |
sound s = SoundM s () | |
main = do | |
x <- obtain audio data ... | |
y <- obtain audio data ... | |
play $ do | |
sound (Audio x) | |
sound (Volume 0.90 (Audio y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment