Skip to content

Instantly share code, notes, and snippets.

@adkelley
Last active May 29, 2018 00:41
Show Gist options
  • Save adkelley/2331757e9aac07332e6aa14ed1df6f46 to your computer and use it in GitHub Desktop.
Save adkelley/2331757e9aac07332e6aa14ed1df6f46 to your computer and use it in GitHub Desktop.
Candidate Solution for AudioBufferSource options
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