twiml 0.2.0.1 → 0.2.1.0
raw patch · 43 files changed
+444/−789 lines, 43 filesdep +doctestdep −Cabaldep −Diffdep −HUnitdep ~basedep ~data-defaultdep ~deepseq
Dependencies added: doctest
Dependencies removed: Cabal, Diff, HUnit, should-not-typecheck, twiml
Dependency ranges changed: base, data-default, deepseq, lens, void
Files
- LICENSE +1/−1
- dist/build/GoldenStub/GoldenStub-tmp/GoldenStub.hs +0/−5
- dist/build/ShouldNotTypecheckStub/ShouldNotTypecheckStub-tmp/ShouldNotTypecheckStub.hs +0/−5
- src/Text/XML/Twiml.hs +3/−1
- src/Text/XML/Twiml/Internal.hs +1/−1
- src/Text/XML/Twiml/Internal/TH.hs +4/−4
- src/Text/XML/Twiml/Internal/Twiml.hs +10/−2
- src/Text/XML/Twiml/Lenses.hs +2/−2
- src/Text/XML/Twiml/Syntax.hs +2/−1
- src/Text/XML/Twiml/Types.hs +1/−1
- src/Text/XML/Twiml/Verbs.hs +1/−1
- src/Text/XML/Twiml/Verbs/Dial.hs +45/−3
- src/Text/XML/Twiml/Verbs/End.hs +19/−11
- src/Text/XML/Twiml/Verbs/Enqueue.hs +26/−2
- src/Text/XML/Twiml/Verbs/Gather.hs +33/−2
- src/Text/XML/Twiml/Verbs/Hangup.hs +24/−2
- src/Text/XML/Twiml/Verbs/Leave.hs +24/−2
- src/Text/XML/Twiml/Verbs/Message.hs +23/−12
- src/Text/XML/Twiml/Verbs/Pause.hs +30/−2
- src/Text/XML/Twiml/Verbs/Play.hs +42/−3
- src/Text/XML/Twiml/Verbs/Record.hs +33/−2
- src/Text/XML/Twiml/Verbs/Redirect.hs +28/−2
- src/Text/XML/Twiml/Verbs/Reject.hs +26/−2
- src/Text/XML/Twiml/Verbs/Say.hs +27/−2
- src/Text/XML/Twiml/Verbs/Sms.hs +30/−2
- test/Golden.hs +0/−411
- test/ShouldNotTypecheck.hs +0/−79
- test/doctests.hs +3/−0
- test/examples/dialExample1.txt +0/−14
- test/examples/dialExample3.txt +0/−15
- test/examples/enqueueExample1.txt +0/−12
- test/examples/gatherExample2.txt +0/−19
- test/examples/hangupExample1.txt +0/−12
- test/examples/leaveExample1.txt +0/−12
- test/examples/pauseExample1.txt +0/−16
- test/examples/playExample1.txt +0/−12
- test/examples/playExample2.txt +0/−12
- test/examples/recordExample2.txt +0/−19
- test/examples/redirectExample1.txt +0/−14
- test/examples/rejectExample2.txt +0/−12
- test/examples/sayExample2.txt +0/−13
- test/examples/smsExample2.txt +0/−16
- twiml.cabal +6/−28
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2013, Mark Andrus Roberts+Copyright (C) 2018, Mark Andrus Roberts All rights reserved.
− dist/build/GoldenStub/GoldenStub-tmp/GoldenStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import Golden ( tests )-main :: IO ()-main = stubMain tests
− dist/build/ShouldNotTypecheckStub/ShouldNotTypecheckStub-tmp/ShouldNotTypecheckStub.hs
@@ -1,5 +0,0 @@-module Main ( main ) where-import Distribution.Simple.Test.LibV09 ( stubMain )-import ShouldNotTypecheck ( tests )-main :: IO ()-main = stubMain tests
src/Text/XML/Twiml.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -10,6 +10,8 @@ ( MessagingTwiml(..) , VoiceTwiml(..) , response+ , voiceResponse+ , messagingResponse , module X ) where
src/Text/XML/Twiml/Internal.hs view
@@ -18,7 +18,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Internal--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional
src/Text/XML/Twiml/Internal/TH.hs view
@@ -4,7 +4,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Internal.TH--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -317,7 +317,7 @@ -- | @data Foo@ #if MIN_VERSION_template_haskell(2,12,0)- emptyDataDecl = DataD [] conName [] Nothing [] $ DerivClause Nothing []+ emptyDataDecl = DataD [] conName [] Nothing [] [DerivClause Nothing []] #else #if MIN_VERSION_template_haskell(2,11,0) emptyDataDecl = DataD [] conName [] Nothing [] []@@ -357,7 +357,7 @@ -- | @data FooF i a where FooF :: a -> FooF '[Foo] a@ #if MIN_VERSION_template_haskell(2,12,0)- gadt = DataD [] conNameF tyVarBndrs Nothing [con] $ DerivClause Nothing []+ gadt = DataD [] conNameF tyVarBndrs Nothing [con] [DerivClause Nothing []] #else #if MIN_VERSION_template_haskell(2,11,0) gadt = DataD [] conNameF tyVarBndrs Nothing [con] []@@ -485,7 +485,7 @@ -- -- All record fields should be camelCased and prefixed with "_foo". #if MIN_VERSION_template_haskell(2,12,0)- attributes = DataD [] attributesName [] Nothing [RecC attributesName (parametersToVarStrictTypes makeAttr parameters)] . DerivClause Nothing $ ConT <$> [dataN, eqN, genericN, nfdataN, ordN, readN, showN]+ attributes = DataD [] attributesName [] Nothing [RecC attributesName (parametersToVarStrictTypes makeAttr parameters)] . pure . DerivClause Nothing $ ConT <$> [dataN, eqN, genericN, nfdataN, ordN, readN, showN] #else #if MIN_VERSION_template_haskell(2,11,0) attributes = DataD [] attributesName [] Nothing [RecC attributesName (parametersToVarStrictTypes makeAttr parameters)] $ ConT <$> [dataN, eqN, genericN, nfdataN, ordN, readN, showN]
src/Text/XML/Twiml/Internal/Twiml.hs view
@@ -20,7 +20,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Internal.Twiml--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -45,6 +45,8 @@ , TwimlLike , TwimlLike' , response+ , voiceResponse+ , messagingResponse -- ** Nouns , DialNoun(..) , DialNounF(..)@@ -695,5 +697,11 @@ type TwimlLike' f = IxFree f +voiceResponse :: IxFree VoiceVerbsF i Void -> VoiceTwiml+voiceResponse = VoiceTwiml++messagingResponse :: IxFree MessagingVerbsF i Void -> MessagingTwiml+messagingResponse = MessagingTwiml+ response :: IxFree VoiceVerbsF i Void -> VoiceTwiml-response = VoiceTwiml+response = voiceResponse
src/Text/XML/Twiml/Lenses.hs view
@@ -5,13 +5,13 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Lenses--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional -- -- This module defines lenses for use with TwiML attributes. Lenses are--- re-exported by the @<Text-XML-Twiml-Verbs.html Text.XML.Twiml.Verbs> modules.+-- re-exported by the <Text-XML-Twiml-Verbs.html Text.XML.Twiml.Verbs> modules. ------------------------------------------------------------------------------- module Text.XML.Twiml.Lenses where
src/Text/XML/Twiml/Syntax.hs view
@@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Syntax--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -20,6 +20,7 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml --
src/Text/XML/Twiml/Types.hs view
@@ -19,7 +19,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Types--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional
src/Text/XML/Twiml/Verbs.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional
src/Text/XML/Twiml/Verbs/Dial.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Dial--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -64,16 +66,56 @@ import Text.XML.Twiml.Internal.Twiml import Text.XML.Twiml.Types +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Dial a number. Example: -#include "dialExample1.txt"+>>> :{+let example1 :: VoiceTwiml+ example1 =+ voiceResponse $ do+ dial "415-123-4567" def+ say "Goodbye" def+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example1+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Dial>415-123-4567</Dial>+ <Say>Goodbye</Say>+</Response> -} dial :: IsTwimlLike f Dial => String -> DialAttributes -> TwimlLike f Dial () dial a b = iliftF . inj $ DialF (pure a) b () {- | Dial a number or 'DialNoun'. Example: -#include "dialExample3.txt"+>>> :{+let example2 :: VoiceTwiml+ example2 =+ voiceResponse $ do+ dial' (Left . dialNoun $ number "+15558675309" def) $+ def & callerId .~ Just "+15551112222"+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example2+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Dial callerId="+15551112222">+ <Number>+15558675309</Number>+ </Dial>+</Response> -} dial' :: IsTwimlLike f Dial => Either DialNoun String -> DialAttributes -> TwimlLike f Dial () dial' a b = iliftF . inj $ DialF a b ()
src/Text/XML/Twiml/Verbs/End.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.End--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,7 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -30,20 +31,27 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Terminate a TwiML response, or construct an empty TwiML response. Example: -@-example :: VoiceTwiml-example =- response $ do- 'end'- where Twiml.Syntax{..} = def-@+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ end+ where Twiml.Syntax{..} = def+:} ->>> show example+>>> putStr $ show example <?xml version="1.0" encoding="UTF-8"?>-<Response>-</Response>+<Response /> -} end :: IsTwimlLike f End => TwimlLike f End a end = iliftF $ inj EndF
src/Text/XML/Twiml/Verbs/Enqueue.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Enqueue--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,9 +34,31 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Enqueue a caller in a queue. Example: -#include "enqueueExample1.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ enqueue "support" $ def & waitURL .~ parseURL "wait-music.xml"+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Enqueue waitUrl="wait-music.xml">support</Enqueue>+</Response> -} enqueue :: IsTwimlLike f Enqueue => String -> EnqueueAttributes -> TwimlLike f Enqueue () enqueue a b = iliftF . inj $ EnqueueF a b ()
src/Text/XML/Twiml/Verbs/Gather.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Gather--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -33,9 +35,38 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "gatherExample2.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ gather (def & action .~ parseURL "/process_gather.php"+ & method .~ Just GET) $ do+ say "Please enter your account number, followed by the pound sign" def+ end+ say "We didn't receive any input. Goodbye!" def+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Gather action="/process_gather.php" method="GET">+ <Say>Please enter your account number, followed by the pound sign</Say>+ </Gather>+ <Say>We didn't receive any input. Goodbye!</Say>+</Response> -} gather :: (IsTwimlLike f Gather, Nest i In Gather) => GatherAttributes -> TwimlLike' VoiceVerbsF i Void -> TwimlLike f Gather () gather a b = iliftF . inj $ GatherF a b ()
src/Text/XML/Twiml/Verbs/Hangup.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Hangup--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,7 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -31,9 +32,30 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Hangup a call. Example: -#include "hangupExample1.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ hangup+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Hangup />+</Response> -} hangup :: IsTwimlLike f Hangup => TwimlLike f Hangup a hangup = iliftF . inj $ HangupF
src/Text/XML/Twiml/Verbs/Leave.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Leave--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,7 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -31,9 +32,30 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Leave a queue. Example: -#include "leaveExample1.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ leave+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Leave />+</Response> -} leave :: IsTwimlLike f Leave => TwimlLike f Leave a leave = iliftF . inj $ LeaveF
src/Text/XML/Twiml/Verbs/Message.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Message--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,7 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,20 +33,30 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -@-example :: MessagingTwiml-example =- response $ do- 'end'- where Twiml.Syntax{..} = def-@+>>> :{+let example :: MessagingTwiml+ example =+ messagingResponse $ do+ message "Store Location: 123 Easy St." def+ end+ where Twiml.Syntax{..} = def+:} -> <?xml version="1.0" encoding="UTF-8"?>-> <Response>-> <Message>Store Location: 123 Easy St.</Message>-> </Response>+>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Message>Store Location: 123 Easy St.</Message>+</Response> -} message :: IsTwimlLike f Message => String -> MessageAttributes -> TwimlLike f Message () message a b = iliftF . inj $ MessageF a b ()
src/Text/XML/Twiml/Verbs/Pause.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Pause--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,9 +34,35 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "pauseExample1.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ say "I will pause 10 seconds starting now!" def+ pause $ def & duration .~ Just 10+ say "I just paused 10 seconds" def+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Say>I will pause 10 seconds starting now!</Say>+ <Pause length="10" />+ <Say>I just paused 10 seconds</Say>+</Response> -} pause :: IsTwimlLike f Pause => PauseAttributes -> TwimlLike f Pause () pause a = iliftF . inj $ PauseF a ()
src/Text/XML/Twiml/Verbs/Play.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Play--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,9 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default+-- import Data.Maybe -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -34,16 +37,52 @@ import Text.XML.Twiml.Internal.Twiml import Text.XML.Twiml.Types +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Data.Maybe+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "playExample1.txt"+>>> :{+let example1 :: VoiceTwiml+ example1 =+ voiceResponse $ do+ play (fromJust $ parseURL "https://api.twilio.com/cowbell.mp3") def+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example1+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Play>https://api.twilio.com/cowbell.mp3</Play>+</Response> -} play :: IsTwimlLike f Play => URL -> PlayAttributes -> TwimlLike f Play () play a b = iliftF . inj $ PlayF (pure a) b () {- | Example: -#include "playExample2.txt"+>>> :{+let example2 :: VoiceTwiml+ example2 =+ voiceResponse $ do+ play' Nothing $ def & digits .~ Just [W, W, W, W, D3]+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example2+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Play digits="wwww3" />+</Response> -} play' :: IsTwimlLike f Play => Maybe URL -> PlayAttributes -> TwimlLike f Play () play' a b = iliftF . inj $ PlayF a b ()
src/Text/XML/Twiml/Verbs/Record.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Record--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,9 +34,38 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "recordExample2.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ say "Please leave a message at the beep. Press the star key when finished." def+ record $ def & action .~ parseURL "http://foo.edu/handleRecording.php"+ & method .~ Just GET+ & maxLength .~ Just 20+ & finishOnKey .~ Just KStar+ say "I did not receive a recording" def+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Say>Please leave a message at the beep. Press the star key when finished.</Say>+ <Record action="http://foo.edu/handleRecording.php" method="GET" finishOnKey="*" maxLength="20" />+ <Say>I did not receive a recording</Say>+</Response> -} record :: IsTwimlLike f Record => RecordAttributes -> TwimlLike f Record () record a = iliftF . inj $ RecordF a ()
src/Text/XML/Twiml/Verbs/Redirect.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Redirect--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Data.Default+-- import Data.Maybe -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -33,9 +35,33 @@ import Text.XML.Twiml.Internal.Twiml import Text.XML.Twiml.Types +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Data.Default+-- >>> import Data.Maybe+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "redirectExample1.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ dial "415-123-4567" def+ redirect (fromJust $ parseURL "http://www.foo.com/nextInstructions") def+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Dial>415-123-4567</Dial>+ <Redirect>http://www.foo.com/nextInstructions</Redirect>+</Response> -} redirect :: IsTwimlLike f Redirect => URL -> RedirectAttributes -> TwimlLike f Redirect a redirect a b = iliftF . inj $ RedirectF a b
src/Text/XML/Twiml/Verbs/Reject.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Reject--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,9 +34,31 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "rejectExample2.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ reject $ def & reason .~ Just Busy+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Reject reason="busy" />+</Response> -} reject :: IsTwimlLike f Reject => RejectAttributes -> TwimlLike f Reject a reject a = iliftF . inj $ RejectF a
src/Text/XML/Twiml/Verbs/Say.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Say--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,9 +34,32 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "sayExample2.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ say "Bom dia." $ def & voice .~ Just (Alice $ Just PtBR)+ & loop .~ Just 2+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Say voice="alice" loop="2" language="pt-BR">Bom dia.</Say>+</Response> -} say :: IsTwimlLike f Say => String -> SayAttributes -> TwimlLike f Say () say a b = iliftF . inj $ SayF a b ()
src/Text/XML/Twiml/Verbs/Sms.hs view
@@ -3,7 +3,7 @@ ------------------------------------------------------------------------------- -- | -- Module : Text.XML.Twiml.Verbs.Sms--- Copyright : (C) 2014-15 Mark Andrus Roberts+-- Copyright : (C) 2018 Mark Andrus Roberts -- License : BSD-style (see the file LICENSE) -- Maintainer : Mark Andrus Roberts <markandrusroberts@gmail.com> -- Stability : provisional@@ -15,6 +15,8 @@ -- {-\# LANGUAGE RecordWildCards \#-} -- -- import Prelude+-- import Control.Lens+-- import Data.Default -- import Text.XML.Twiml -- import qualified Text.XML.Twiml.Syntax as Twiml -- @@@ -32,9 +34,35 @@ import Text.XML.Twiml.Internal import Text.XML.Twiml.Internal.Twiml +-- $setup+-- >>> :set -XRebindableSyntax+-- >>> :set -XRecordWildCards+-- >>> import Prelude+-- >>> import Control.Lens+-- >>> import Data.Default+-- >>> import Text.XML.Twiml+-- >>> import qualified Text.XML.Twiml.Syntax as Twiml+ {- | Example: -#include "smsExample2.txt"+>>> :{+let example :: VoiceTwiml+ example =+ voiceResponse $ do+ say "Our store is located at 123 Easy St." def+ sms "Store Location: 123 Easy St." $ def+ & action .~ parseURL "/smsHandler.php"+ & method .~ Just POST+ end+ where Twiml.Syntax{..} = def+:}++>>> putStr $ show example+<?xml version="1.0" encoding="UTF-8"?>+<Response>+ <Say>Our store is located at 123 Easy St.</Say>+ <Sms action="/smsHandler.php" method="POST">Store Location: 123 Easy St.</Sms>+</Response> -} sms :: IsTwimlLike f Sms => String -> SmsAttributes -> TwimlLike f Sms () sms a b = iliftF . inj $ SmsF a b ()
− test/Golden.hs
@@ -1,411 +0,0 @@-{-# OPTIONS_GHC -cpp -optP -P -Itest/examples #-}-{-# LANGUAGE RebindableSyntax #-}-{-# LANGUAGE RecordWildCards #-}--module Golden where--import Text.XML.Twiml-import qualified Text.XML.Twiml.Syntax as Twiml--import Control.Monad-import Control.Lens-import Data.Algorithm.Diff-import Data.Algorithm.DiffOutput-import Data.Default-import Data.Maybe (fromJust)-import Data.String-import Distribution.TestSuite-import System.IO--import Prelude--{- Say -}--sayExample1 :: VoiceTwiml-sayExample1 =- response $ do- say "Hello World" def- end- where Twiml.Syntax{..} = def--{--sayExample2 :: VoiceTwiml-sayExample2 =- response $ do- say "Bom dia." $ def & voice .~ Just (Alice $ Just PtBR)- & loop .~ Just 2- end- where Twiml.Syntax{..} = def--}--#include "sayExample2.hs"--sayExamples :: [(VoiceTwiml, FilePath)]-sayExamples =- [ (sayExample1, "test/xml/sayExample1.xml")- , (sayExample2, "test/xml/sayExample2.xml")- ]--{- Play -}--{--playExample1 :: VoiceTwiml-playExample1 =- response $ do- play (fromJust $ parseURL "https://api.twilio.com/cowbell.mp3") def- end- where Twiml.Syntax{..} = def--}--#include "playExample1.hs"--{--playExample2 :: VoiceTwiml-playExample2 =- response $ do- play' Nothing $ def & digits .~ Just [W, W, W, W, D3]- end- where Twiml.Syntax{..} = def--}--#include "playExample2.hs"--playExamples :: [(VoiceTwiml, FilePath)]-playExamples =- [ (playExample1, "test/xml/playExample1.xml")- , (playExample2, "test/xml/playExample2.xml")- ]--{- Gather -}--gatherExample1 :: VoiceTwiml-gatherExample1 =- response $ do- gather def end- end- where Twiml.Syntax{..} = def--{--gatherExample2 :: VoiceTwiml-gatherExample2 =- response $ do- gather (def & action .~ parseURL "/process_gather.php"- & method .~ Just GET) $ do- say "Please enter your account number, followed by the pound sign" def- end- say "We didn't receive any input. Goodbye!" def- end- where Twiml.Syntax{..} = def--}--#include "gatherExample2.hs"--gatherExamples :: [(VoiceTwiml, FilePath)]-gatherExamples =- [ (gatherExample1, "test/xml/gatherExample1.xml")- , (gatherExample2, "test/xml/gatherExample2.xml")- ]--{- Record -}--recordExample1 :: VoiceTwiml-recordExample1 =- response $ do- record def- end- where Twiml.Syntax{..} = def--{--recordExample2 :: VoiceTwiml-recordExample2 =- response $ do- say "Please leave a message at the beep. Press the star key when finished." def- record $ def & action .~ parseURL "http://foo.edu/handleRecording.php"- & method .~ Just GET- & maxLength .~ Just 20- & finishOnKey .~ Just KStar- say "I did not receive a recording" def- end- where Twiml.Syntax{..} = def--}--#include "recordExample2.hs"--recordExample3 :: VoiceTwiml-recordExample3 =- response $ do- record $ def & transcribe .~ Just True- & transcribeCallback .~ parseURL "/handle_transcribe.php"- end- where Twiml.Syntax{..} = def--recordExamples :: [(VoiceTwiml, FilePath)]-recordExamples =- [ (recordExample1, "test/xml/recordExample1.xml")- , (recordExample2, "test/xml/recordExample2.xml")- , (recordExample3, "test/xml/recordExample3.xml")- ]--{- Sms -}--smsExample1 :: VoiceTwiml-smsExample1 =- response $ do- say "Our store is located at 123 Easy St." def- sms "Store Location: 123 Easy St." def- end- where Twiml.Syntax{..} = def--{--smsExample2 :: VoiceTwiml-smsExample2 =- response $ do- say "Our store is located at 123 Easy St." def- sms "Store Location: 123 Easy St." $ def- & action .~ parseURL "/smsHandler.php"- & method .~ Just POST- end- where Twiml.Syntax{..} = def--}--#include "smsExample2.hs"--smsExample3 :: VoiceTwiml-smsExample3 =- response $ do- say "Our store is located at 123 Easy St." def- sms "Store Location: 123 Easy St." $ def- & statusCallback .~ parseURL "/smsHandler.php"- end- where Twiml.Syntax{..} = def--smsExamples :: [(VoiceTwiml, FilePath)]-smsExamples =- [ (smsExample1, "test/xml/smsExample1.xml")- , (smsExample2, "test/xml/smsExample2.xml")- , (smsExample3, "test/xml/smsExample3.xml")- ]--{- Dial -}--{--dialExample1 :: VoiceTwiml-dialExample1 =- response $ do- dial "415-123-4567" def- say "Goodbye" def- end- where Twiml.Syntax{..} = def--}--#include "dialExample1.hs"--dialExample2 :: VoiceTwiml-dialExample2 =- response $ do- dial "415-123-4567" $ def- & action .~ parseURL "/handleDialCallStatus.php"- & method .~ Just GET- say "I am unreachable" def- end- where Twiml.Syntax{..} = def--{--dialExample3 :: VoiceTwiml-dialExample3 =- response $ do- dial' (Left . dialNoun $ number "+15558675309" def) $ def- & callerId .~ Just "+15551112222"- end- where Twiml.Syntax{..} = def--}--#include "dialExample3.hs"--dialExamples :: [(VoiceTwiml, FilePath)]-dialExamples =- [ (dialExample1, "test/xml/dialExample1.xml")- , (dialExample2, "test/xml/dialExample2.xml")- , (dialExample3, "test/xml/dialExample3.xml")- ]---- TODO: Dial nouns...--{- Enqueue -}--{--enqueueExample1 :: VoiceTwiml-enqueueExample1 =- response $ do- enqueue "support" $ def & waitURL .~ parseURL "wait-music.xml"- end- where Twiml.Syntax{..} = def--}--#include "enqueueExample1.hs"--enqueueExamples :: [(VoiceTwiml, FilePath)]-enqueueExamples =- [ (enqueueExample1, "test/xml/enqueueExample1.xml")- ]--{- Leave -}--{--leaveExample1 :: VoiceTwiml-leaveExample1 =- response $ do- leave- end- where Twiml.Syntax{..} = def--}--#include "leaveExample1.hs"--leaveExamples :: [(VoiceTwiml, FilePath)]-leaveExamples =- [ (leaveExample1, "test/xml/leaveExample1.xml")- ]--{- Hangup -}--{--hangupExample1 :: VoiceTwiml-hangupExample1 =- response $ do- hangup- end- where Twiml.Syntax{..} = def--}--#include "hangupExample1.hs"--hangupExamples :: [(VoiceTwiml, FilePath)]-hangupExamples =- [ (hangupExample1, "test/xml/hangupExample1.xml")- ]--{- Redirect -}--{--redirectExample1 :: VoiceTwiml-redirectExample1 =- response $ do- dial "415-123-4567" def- redirect (fromJust $ parseURL "http://www.foo.com/nextInstructions") def- end- where Twiml.Syntax{..} = def--}--#include "redirectExample1.hs"--redirectExample2 :: VoiceTwiml-redirectExample2 =- response $ do- redirect (fromJust $ parseURL "../nextInstructions") def- end- where Twiml.Syntax{..} = def--redirectExamples :: [(VoiceTwiml, FilePath)]-redirectExamples =- [ (redirectExample1, "test/xml/redirectExample1.xml")- , (redirectExample2, "test/xml/redirectExample2.xml")- ]--{- Reject -}--rejectExample1 :: VoiceTwiml-rejectExample1 =- response $ do- reject def- end- where Twiml.Syntax{..} = def--{--rejectExample2 :: VoiceTwiml-rejectExample2 =- response $ do- reject $ def & reason .~ Just Busy- end- where Twiml.Syntax{..} = def--}--#include "rejectExample2.hs"--rejectExamples :: [(VoiceTwiml, FilePath)]-rejectExamples =- [ (rejectExample1, "test/xml/rejectExample1.xml")- , (rejectExample2, "test/xml/rejectExample2.xml")- ]--{- Pause -}--{--pauseExample1 :: VoiceTwiml-pauseExample1 =- response $ do- say "I will pause 10 seconds starting now!" def- pause $ def & duration .~ Just 10- say "I just paused 10 seconds" def- end- where Twiml.Syntax{..} = def--}--#include "pauseExample1.hs"--pauseExample2 :: VoiceTwiml-pauseExample2 =- response $ do- pause $ def & duration .~ Just 5- say "Hi there." def- end- where Twiml.Syntax{..} = def--pauseExamples :: [(VoiceTwiml, FilePath)]-pauseExamples =- [ (pauseExample1, "test/xml/pauseExample1.xml")- , (pauseExample2, "test/xml/pauseExample2.xml")- ]--{- Main -}--examples :: [(VoiceTwiml, FilePath)]-examples = concat- [ sayExamples- , playExamples- , gatherExamples- , recordExamples- , smsExamples- , dialExamples- , enqueueExamples- , leaveExamples- , hangupExamples- , redirectExamples- , rejectExamples- ] --ifThenElse :: Bool -> t -> t -> t-ifThenElse b x y | b = x- | otherwise = y--tests :: IO [Test]-tests = return $ map check examples--check :: (VoiceTwiml, FilePath) -> Test-check (twiml, filePath) = Test test- where test = TestInstance {- run = do- let a = show twiml- b <- readFile filePath- let equal = a == b- unless equal $ do- putStrLn ""- putStrLn . ppDiff $ getGroupedDiff (lines b) (lines a)- return . Finished $ if equal- then Pass- else Error "Check preceding diff",- name = filePath,- tags = [],- options = [],- setOption = \_ _ -> Right test- }
− test/ShouldNotTypecheck.hs
@@ -1,79 +0,0 @@-{-#OPTIONS_GHC -fdefer-type-errors -fno-defer-typed-holes #-}-{-#LANGUAGE CPP #-}-{-#LANGUAGE DataKinds #-}-{-#LANGUAGE RebindableSyntax #-}-{-#LANGUAGE RecordWildCards #-}--module ShouldNotTypecheck where--import Control.DeepSeq (NFData)-import Distribution.TestSuite-import qualified Test.HUnit as H-import Test.ShouldNotTypecheck--import Prelude---- NOTE: I don't really understand why these aren't working. I see the warning--- when the module is compiled.--tests :: IO [Test]-tests = return- []-{-- [ makeTest "\"Cannot nest <Gather> in <Gather>\"" gatherInGather- -- , makeTest "\"Cannot nest <Record> in <Gather>\"" recordInGather- -- , makeTest "\"Cannot nest <Sms> in <Gather>\"" smsInGather- -- , makeTest "\"Cannot nest <Dial> in <Gather>\"" dialInGather- -- , makeTest "\"Cannot nest <Enqueue> in <Gather>\"" enqueueInGather- -- , makeTest "\"Cannot nest <Leave> in <Gather>\"" leaveInGather- -- , makeTest "\"Cannot nest <Hangup> in <Gather>\"" hangupInGather- -- , makeTest "\"Cannot nest <Redirect> in <Gather>\"" redirectInGather- -- , makeTest "\"Cannot nest <Reject> in <Gather>\"" rejectInGather- ]--}--makeTest :: NFData a => String -> a -> Test-makeTest name twiml = Test test- where test = TestInstance {- run = runTest . H.TestCase $ shouldNotTypecheck twiml,- name = name,- tags = [],- options = [],- setOption = \_ _ -> Right test- }--runTest :: H.Test -> IO Progress-runTest = fmap snd . H.performTest onStart onError onFailure (Finished Pass)- where- onStart :: H.State -> Progress -> IO Progress- onStart _ = return--#if MIN_VERSION_HUnit(1,3,0)- onError :: a -> String -> H.State -> Progress -> IO Progress- onError _ msg _ _ = return $ Finished (Error msg)-- onFailure :: a -> String -> H.State -> Progress -> IO Progress- onFailure _ msg _ _ = return $ Finished (Fail msg)-#else- onError :: String -> H.State -> Progress -> IO Progress- onError msg _ _ = return $ Finished (Error msg)-- onFailure :: String -> H.State -> Progress -> IO Progress- onFailure msg _ _ = return $ Finished (Fail msg)-#endif--{--someGather :: Twiml' '[Gather] Void-someGather =- do- gather def end- end- where Twiml.Syntax{..} = def--gatherInGather :: Twiml-gatherInGather =- response $ do- gather def someGather- end- where Twiml.Syntax{..} = def--}
+ test/doctests.hs view
@@ -0,0 +1,3 @@+import Test.DocTest+main :: IO ()+main = doctest ["src"]
− test/examples/dialExample1.txt
@@ -1,14 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> dial "415-123-4567" def-> say "Goodbye" def-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Dial>415-123-4567</Dial>- <Say>Goodbye</Say>-</Response>
− test/examples/dialExample3.txt
@@ -1,15 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> dial' (Left . dialNoun $ number "+15558675309" def) $ def-> & callerId .~ Just "+15551112222"-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Dial callerId="+15551112222">- <Number>+15558675309</Number>- </Dial>-</Response>
− test/examples/enqueueExample1.txt
@@ -1,12 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> enqueue "support" $ def & waitURL .~ parseURL "wait-music.xml"-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Enqueue waitUrl="wait-music.xml">support</Enqueue>-</Response>
− test/examples/gatherExample2.txt
@@ -1,19 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> gather (def & action .~ parseURL "/process_gather.php"-> & method .~ Just GET) $ do-> say "Please enter your account number, followed by the pound sign" def-> end-> say "We didn't receive any input. Goodbye!" def-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Gather action="/process_gather.php" method="GET">- <Say>Please enter your account number, followed by the pound sign</Say>- </Gather>- <Say>We didn't receive any input. Goodbye!</Say>-</Response>
− test/examples/hangupExample1.txt
@@ -1,12 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> hangup-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Hangup />-</Response>
− test/examples/leaveExample1.txt
@@ -1,12 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> leave-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Leave />-</Response>
− test/examples/pauseExample1.txt
@@ -1,16 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> say "I will pause 10 seconds starting now!" def-> pause $ def & duration .~ Just 10-> say "I just paused 10 seconds" def-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Say>I will pause 10 seconds starting now!</Say>- <Pause length="10"/>- <Say>I just paused 10 seconds</Say>-</Response>
− test/examples/playExample1.txt
@@ -1,12 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> play (fromJust $ parseURL "https://api.twilio.com/cowbell.mp3") def-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Play>https://api.twilio.com/cowbell.mp3</Play>-</Response>
− test/examples/playExample2.txt
@@ -1,12 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> play' Nothing $ def & digits .~ Just [W, W, W, W, D3]-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Play digits="wwww3" />-</Response>
− test/examples/recordExample2.txt
@@ -1,19 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> say "Please leave a message at the beep. Press the star key when finished." def-> record $ def & action .~ parseURL "http://foo.edu/handleRecording.php"-> & method .~ Just GET-> & maxLength .~ Just 20-> & finishOnKey .~ Just KStar-> say "I did not receive a recording" def-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Say>Please leave a message at the beep. Press the star key when finished.</Say>- <Record action="http://foo.edu/handleRecording.php" method="GET" finishOnKey="*" maxLength="20" />- <Say>I did not receive a recording</Say>-</Response>
− test/examples/redirectExample1.txt
@@ -1,14 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> dial "415-123-4567" def-> redirect (fromJust $ parseURL "http://www.foo.com/nextInstructions") def-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Dial>415-123-4567</Dial>- <Redirect>http://www.foo.com/nextInstructions</Redirect>-</Response>
− test/examples/rejectExample2.txt
@@ -1,12 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> reject $ def & reason .~ Just Busy-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Reject reason="busy" />-</Response>
− test/examples/sayExample2.txt
@@ -1,13 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> say "Bom dia." $ def & voice .~ Just (Alice $ Just PtBR)-> & loop .~ Just 2-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Say voice="alice" loop="2" language="pt-BR">Bom dia.</Say>-</Response>
− test/examples/smsExample2.txt
@@ -1,16 +0,0 @@-> example :: VoiceTwiml-> example =-> response $ do-> say "Our store is located at 123 Easy St." def-> sms "Store Location: 123 Easy St." $ def-> & action .~ parseURL "/smsHandler.php"-> & method .~ Just POST-> end-> where Twiml.Syntax{..} = def-->>> show example-<?xml version="1.0" encoding="UTF-8"?>-<Response>- <Say>Our store is located at 123 Easy St.</Say>- <Sms action="/smsHandler.php" method="POST">Store Location: 123 Easy St.</Sms>-</Response>
twiml.cabal view
@@ -1,5 +1,5 @@ name: twiml-version: 0.2.0.1+version: 0.2.1.0 synopsis: TwiML library for Haskell description: TwiML library for Haskell homepage: https://github.com/markandrus/twiml-haskell@@ -12,7 +12,6 @@ build-type: Simple cabal-version: >=1.8 tested-with: GHC == 7.10.1, GHC == 7.10.2, GHC == 8.0.1, GHC == 8.0.2-data-files: test/examples/*.txt source-repository head type: git@@ -55,29 +54,8 @@ xml >=1.3 ghc-options: -Wall -fno-warn-name-shadowing -fno-warn-orphans -fno-warn-unused-do-bind -test-suite Golden- hs-source-dirs: test- type: detailed-0.9- test-module: Golden- build-depends: base,- Cabal >=1.16.0,- data-default,- Diff ==0.3.2,- lens,- twiml- ghc-options: -Wall -fno-warn-name-shadowing -fno-warn-orphans -fno-warn-unused-do-bind--test-suite ShouldNotTypecheck- hs-source-dirs: test- type: detailed-0.9- test-module: ShouldNotTypecheck- build-depends: base,- Cabal >=1.16.0,- data-default,- deepseq,- HUnit >=1.2 && <1.6,- lens,- should-not-typecheck ==2.0.*,- twiml,- void- ghc-options: -Wall -fno-warn-name-shadowing -fno-warn-orphans -fno-warn-unused-do-bind+test-suite doctests+ type: exitcode-stdio-1.0+ ghc-options: -threaded+ main-is: test/doctests.hs+ build-depends: base, doctest >= 0.8