Last active
May 29, 2018 00:41
-
-
Save adkelley/2331757e9aac07332e6aa14ed1df6f46 to your computer and use it in GitHub Desktop.
Candidate Solution for AudioBufferSource options
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
module Main where | |
import Prelude | |
import Control.Monad.Eff (Eff) | |
import Control.Monad.Eff.Console (CONSOLE, log) | |
import Data.Maybe (Maybe(..)) | |
type Secods = Number | |
type Start = | |
{ when :: Maybe Seconds | |
, offset :: Maybe Seconds | |
, duration :: Maybe Seconds | |
} | |
checkStart :: ∀ e. Start → Eff (console :: CONSOLE | e) Unit | |
checkStart { when: Just x, offset: Just y, duration: Just z } = log "when, offset, duration" | |
checkStart { when: Just x, offset: Just y, duration: Nothing } = log "when, offset" | |
checkStart { when: Just x, offset: Nothing, duration: Nothing } = log "when" | |
checkStart { when: _, offset: _, duration: _ } = log "defaults" | |
checkStop :: ∀ e. Maybe Number → Eff (console :: CONSOLE | e) Unit | |
checkStop (Just x) = log "when" | |
checkStop Nothing = log "default" | |
main :: forall e. Eff (console :: CONSOLE | e) Unit | |
main = do | |
log "AudioBufferSource Start" | |
let r = { when: Just 10.0, offset: Nothing, duration: Nothing} | |
checkStart r | |
let s = { when: Just 10.0, offset: Just 1.0, duration: Nothing} | |
checkStart s | |
let t = { when: Just 10.0, offset: Just 1.0, duration: Just 20.0} | |
checkStart t | |
let u = { when: Nothing, offset: Nothing, duration: Nothing} | |
checkStart u | |
log "AudioBufferSource Stop" | |
let v = Just 5.0 | |
checkStop v | |
let w = Nothing | |
checkStop w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment