+-- | Type-safe bindings to EsounD with monadic regions.
+module Sound.EsounD
+ ( Player
+ , openPlayer
+ )
+ where
+
+import Control.Monad.CatchIO
+import Control.Monad.Trans.Region
+import Network
+import System.IO.SaferFileHandles
+
+{-
+data Mono
+data Stereo
+
+data Recorder frame channels
+data Filter frame channels
+data Sampler
+-}
+
+-- ^ An ESD handle for playing a stream.
+data Player frame channels (r ∷ * → *)
+ = Player {
+ plRate ∷ Int
+ , plHandle ∷ RegionalFileHandle WriteMode r
+ }
+
+instance Dup (Player frame channels) where
+ dup pl
+ = do h' ← dup (plHandle pl)
+ return pl { plHandle = h' }
+
+-- ^ Open an ESD handle for playing a stream.
+openPlayer ∷ MonadCatchIO pr
+ ⇒ Int -- ^ sample rate for the stream.
+ → HostName -- ^ host to connect to.
+ → Maybe String -- ^ name used to identify this stream to
+ -- ESD (if any).
+ → RegionT s pr (Player frame channels (RegionT s pr))
+openPlayer rate host name
+ = return Player {
+ plRate = rate
+ , plHandle = error "FIXME: not implemented"
+ }