twiml-0.2.0.0: src/Text/XML/Twiml/Syntax.hs
{-#LANGUAGE DataKinds #-}
{-#LANGUAGE KindSignatures #-}
{-#LANGUAGE NoImplicitPrelude #-}
{-#LANGUAGE PolyKinds #-}
{-#LANGUAGE RankNTypes #-}
{-#LANGUAGE TypeOperators #-}
-------------------------------------------------------------------------------
-- |
-- Module : Text.XML.Twiml.Syntax
-- Copyright : (C) 2014-15 Mark Andrus Roberts
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com>
-- Stability : provisional
--
-- This module, in combination with the @RebindableSyntax@ and @RecordWilCards@
-- extensions, allows you to write TwiML using do-notation. For example,
--
-- @
-- {-\# LANGUAGE RebindableSyntax \#-}
-- {-\# LANGUAGE RecordWildCards \#-}
--
-- import Prelude
-- import Text.XML.Twiml
-- import qualified Text.XML.Twiml.Syntax as Twiml
--
-- example :: 'VoiceTwiml'
-- example =
-- 'response' $ do
-- 'say' "Hello World" def
-- 'end'
-- where Twiml.'Syntax'{..} = def
-- @
--
-- This pattern is due to a
-- <https://mail.haskell.org/pipermail/haskell-cafe/2015-June/120222.html suggestion from Adam Bergmark on Haskell-Cafe>.
-------------------------------------------------------------------------------
module Text.XML.Twiml.Syntax where
import Data.Default
import Prelude (const)
import Text.XML.Twiml.Internal
data Syntax (m :: [k] -> * -> *) (i :: [k]) (j :: [k]) (a :: *) (b :: *) = Syntax {
(>>=) :: m i a -> (a -> m j b) -> m (i <> j) b
, (>>) :: m i a -> m j b -> m (i <> j) b
, return :: a -> m Identity a
}
instance IxMonad m => Default (Syntax m i j a b) where
def = Syntax ibind (\a b -> a `ibind` const b) ipure