{-#LANGUAGE DataKinds #-} {-#LANGUAGE KindSignatures #-} {-#LANGUAGE NoImplicitPrelude #-} {-#LANGUAGE PolyKinds #-} {-#LANGUAGE RankNTypes #-} {-#LANGUAGE TypeOperators #-} ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Syntax -- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts -- 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 Data.Default -- 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 -- . ------------------------------------------------------------------------------- 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