twiml-0.2.0.1: TwiML library for Haskell

Copyright(C) 2014-15 Mark Andrus Roberts
LicenseBSD-style (see the file LICENSE)
MaintainerMark Andrus Roberts <markandrusroberts@gmail.com>
Stabilityprovisional
Safe HaskellSafe
LanguageHaskell98

Text.XML.Twiml.Internal

Contents

Description

This module exports the machinery necessary to define TwiML in an extensible way.

Synopsis

Data types à la carte

The (:+:) data type and (:<:) type class come from Swierstra's Data types à la carte.

data (f :+: g) a infixr 7 Source #

Constructors

InL (f a) 
InR (g a) 

Instances

(Functor f, Functor g) => f :<: ((:+:) * f g) Source # 

Methods

inj :: f a -> (* :+: f) g a Source #

prj :: (* :+: f) g a -> Maybe (f a) Source #

(Functor f, Functor g, Functor h, (:<:) f g) => f :<: ((:+:) * h g) Source # 

Methods

inj :: f a -> (* :+: h) g a Source #

prj :: (* :+: h) g a -> Maybe (f a) Source #

(Functor g, Functor f) => Functor ((:+:) * f g) Source # 

Methods

fmap :: (a -> b) -> (* :+: f) g a -> (* :+: f) g b #

(<$) :: a -> (* :+: f) g b -> (* :+: f) g a #

(Eq (g a), Eq (f a)) => Eq ((:+:) k f g a) Source # 

Methods

(==) :: (k :+: f) g a -> (k :+: f) g a -> Bool #

(/=) :: (k :+: f) g a -> (k :+: f) g a -> Bool #

(Data a, Data (f a), Data (g a), Typeable (* -> *) f, Typeable (* -> *) g) => Data ((:+:) * f g a) Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall b. b -> c b) -> (* :+: f) g a -> c ((* :+: f) g a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ((* :+: f) g a) #

toConstr :: (* :+: f) g a -> Constr #

dataTypeOf :: (* :+: f) g a -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ((* :+: f) g a)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ((* :+: f) g a)) #

gmapT :: (forall b. Data b => b -> b) -> (* :+: f) g a -> (* :+: f) g a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> (* :+: f) g a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> (* :+: f) g a -> r #

gmapQ :: (forall d. Data d => d -> u) -> (* :+: f) g a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> (* :+: f) g a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> (* :+: f) g a -> m ((* :+: f) g a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> (* :+: f) g a -> m ((* :+: f) g a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> (* :+: f) g a -> m ((* :+: f) g a) #

(Ord (g a), Ord (f a)) => Ord ((:+:) k f g a) Source # 

Methods

compare :: (k :+: f) g a -> (k :+: f) g a -> Ordering #

(<) :: (k :+: f) g a -> (k :+: f) g a -> Bool #

(<=) :: (k :+: f) g a -> (k :+: f) g a -> Bool #

(>) :: (k :+: f) g a -> (k :+: f) g a -> Bool #

(>=) :: (k :+: f) g a -> (k :+: f) g a -> Bool #

max :: (k :+: f) g a -> (k :+: f) g a -> (k :+: f) g a #

min :: (k :+: f) g a -> (k :+: f) g a -> (k :+: f) g a #

(Read (g a), Read (f a)) => Read ((:+:) k f g a) Source # 

Methods

readsPrec :: Int -> ReadS ((k :+: f) g a) #

readList :: ReadS [(k :+: f) g a] #

readPrec :: ReadPrec ((k :+: f) g a) #

readListPrec :: ReadPrec [(k :+: f) g a] #

(Show (g a), Show (f a)) => Show ((:+:) k f g a) Source # 

Methods

showsPrec :: Int -> (k :+: f) g a -> ShowS #

show :: (k :+: f) g a -> String #

showList :: [(k :+: f) g a] -> ShowS #

Generic ((:+:) k f g a) Source # 

Associated Types

type Rep ((:+:) k f g a) :: * -> * #

Methods

from :: (k :+: f) g a -> Rep ((k :+: f) g a) x #

to :: Rep ((k :+: f) g a) x -> (k :+: f) g a #

(NFData (g a), NFData (f a)) => NFData ((:+:) k f g a) Source # 

Methods

rnf :: (k :+: f) g a -> () #

(ToXML (f a), ToXML (g a)) => ToXML ((:+:) k f g a) Source # 

Methods

toXML :: (k :+: f) g a -> [Element] Source #

type Rep ((:+:) k f g a) Source # 
type Rep ((:+:) k f g a) = D1 (MetaData ":+:" "Text.XML.Twiml.Internal" "twiml-0.2.0.1-LqGlAW9ysp41vRhevhGKAu" False) ((:+:) (C1 (MetaCons "InL" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (f a)))) (C1 (MetaCons "InR" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (g a)))))

class (Functor sub, Functor sup) => sub :<: sup where Source #

Minimal complete definition

inj, prj

Methods

inj :: sub a -> sup a Source #

prj :: sup a -> Maybe (sub a) Source #

Instances

Functor f => f :<: f Source # 

Methods

inj :: f a -> f a Source #

prj :: f a -> Maybe (f a) Source #

(Functor f, Functor g) => f :<: ((:+:) * f g) Source # 

Methods

inj :: f a -> (* :+: f) g a Source #

prj :: (* :+: f) g a -> Maybe (f a) Source #

(Functor f, Functor g, Functor h, (:<:) f g) => f :<: ((:+:) * h g) Source # 

Methods

inj :: f a -> (* :+: h) g a Source #

prj :: (* :+: h) g a -> Maybe (f a) Source #

(Functor (f i), (:<:) (f i) ((:+:) * (ClientF i) ((:+:) * (ConferenceF i) ((:+:) * (NumberF i) ((:+:) * (QueueF i) (SipF i)))))) => (f i) :<: (DialNounF i) Source # 

Methods

inj :: f i a -> DialNounF i a Source #

prj :: DialNounF i a -> Maybe (f i a) Source #

(Functor (f i), (:<:) (f i) ((:+:) * (MessageF i) ((:+:) * (RedirectF i) ((:+:) * (SmsF i) (EndF i))))) => (f i) :<: (MessagingVerbsF i) Source # 

Methods

inj :: f i a -> MessagingVerbsF i a Source #

prj :: MessagingVerbsF i a -> Maybe (f i a) Source #

(Functor (f i), (:<:) (f i) ((:+:) * (SayF i) ((:+:) * (PlayF i) ((:+:) * (GatherF i) ((:+:) * (SmsF i) ((:+:) * (DialF i) ((:+:) * (EnqueueF i) ((:+:) * (LeaveF i) ((:+:) * (HangupF i) ((:+:) * (RecordF i) ((:+:) * (RedirectF i) ((:+:) * (RejectF i) ((:+:) * (PauseF i) (EndF i)))))))))))))) => (f i) :<: (VoiceVerbsF i) Source # 

Methods

inj :: f i a -> VoiceVerbsF i a Source #

prj :: VoiceVerbsF i a -> Maybe (f i a) Source #

Elem (∉)

type family Elem (t :: k) (ts :: [k]) :: Bool where ... Source #

Elem is like a promoted elem: it allows us to check whether a type constructor t is present in a list of type constructors ts.

Equations

Elem t '[] = False 
Elem t (t ': ts) = True 
Elem t (u ': ts) = Elem t ts 

type (∉) t ts = Elem t ts ~ False Source #

t ∉ ts is shorthand for asserting that a type constructor t is not present in a list of types constructors ts.

Indexed

Everything in this section comes from Cirdec's excellent answer on a StackOverflow question about indexed free monads. Some names have been changed to follow the patterns established by indexed and indexed-free.

class Functor1 f where Source #

Minimal complete definition

fmap1

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Instances

Functor1 [Type] ClientF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] ConferenceF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] NumberF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] QueueF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] DialNounF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] SipF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] DialF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] EndF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] EnqueueF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] HangupF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] LeaveF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] MessageF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] PauseF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] PlayF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] RecordF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] RedirectF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] RejectF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] SayF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] MessagingVerbsF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] VoiceVerbsF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] GatherF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [Type] SmsF Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [k] f => Functor1 [k] (IxFree k f) Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

class NFData1 f where Source #

Minimal complete definition

rnf1

Methods

rnf1 :: NFData a => f i a -> () Source #

Instances

NFData1 [k] f => NFData1 [k] (IxFree k f) Source # 

Methods

rnf1 :: NFData a => f i a -> () Source #

class Show1 f where Source #

Minimal complete definition

show1

Methods

show1 :: Show a => f i a -> String Source #

Instances

Show1 [Type] DialNounF Source # 

Methods

show1 :: Show a => f i a -> String Source #

Show1 [Type] MessagingVerbsF Source # 

Methods

show1 :: Show a => f i a -> String Source #

Show1 [Type] VoiceVerbsF Source # 

Methods

show1 :: Show a => f i a -> String Source #

Show1 [k] f => Show1 [k] (IxFree k f) Source # 

Methods

show1 :: Show a => f i a -> String Source #

Applicative

class Functor1 f => IxApplicative f where Source #

An applicative functor f indexed by a monoid (M,<>,Identity)

If you import Prelude hiding (<*>) and pure, you can redefine (<*>) and pure to use their indexed equivalents. For example,

import Prelude hiding ((<*>), pure)

pure :: IxApplicative f -> a -> f Identity a
pure = ipure

(<*>) :: IxApplicative f => f i (a -> b) -> f j a -> f (i <> j) b
(<*>) = iap

Minimal complete definition

ipure, iap

Associated Types

type Identity :: k Source #

type (i :: k) <> (j :: k) :: k Source #

Methods

ipure :: a -> f Identity a Source #

The indexed equivalent of pure

iap :: f i (a -> b) -> f j a -> f (i <> j) b Source #

The indexed equivalent of (<*>)

Instances

Functor1 [k] f => IxApplicative [k] (IxFree k f) Source # 

Associated Types

type Identity (IxFree k f) :: k Source #

type ((IxFree k f) <> (i :: IxFree k f)) (j :: IxFree k f) :: k Source #

Methods

ipure :: a -> f (Identity (IxFree k f)) a Source #

iap :: f i (a -> b) -> f j a -> f ((IxFree k f <> i) j) b Source #

Monad

class IxApplicative m => IxMonad m where Source #

A monad m indexed by a monoid (M,<>,Identity)

You can use do-notation with IxMonad by enabling the RebindableSyntax extension and redefining (>>=), (>>), and return. For example,

{-#LANGUAGE RebindableSyntax #-}

import Prelude hiding ((>>=), (>>), return)

(>>=) :: IxMonad m => m i a -> (a -> m j b) -> m (i <> j) b
(>>=) = ibind

(>>) :: IxMonad m => m i a -> m j b -> m (i <> j) b
a >> b = a >>= const b

return :: IxApplicative m => a -> m Identity a
return = ipure

This is the technique employed by the Text.XML.Twiml.Syntax module.

Minimal complete definition

ibind

Methods

ibind :: m i a -> (a -> m j b) -> m (i <> j) b Source #

The indexed equivalent of (>>=)

Instances

(Functor1 [k] m, IxApplicative [k] (IxFree k m)) => IxMonad [k] (IxFree k m) Source # 

Methods

ibind :: m i a -> (a -> m j b) -> m ((IxFree k m <> i) j) b Source #

Free

data IxFree f i a where Source #

A free monad indexed by a monoid (M,++,[])

Constructors

IxPure :: a -> IxFree f '[] a 
IxFree :: WitnessList i => f i (IxFree f j a) -> IxFree f (i ++ j) a 

Instances

NFData1 [k] f => NFData1 [k] (IxFree k f) Source # 

Methods

rnf1 :: NFData a => f i a -> () Source #

(Functor1 [k] m, IxApplicative [k] (IxFree k m)) => IxMonad [k] (IxFree k m) Source # 

Methods

ibind :: m i a -> (a -> m j b) -> m ((IxFree k m <> i) j) b Source #

Functor1 [k] f => IxApplicative [k] (IxFree k f) Source # 

Associated Types

type Identity (IxFree k f) :: k Source #

type ((IxFree k f) <> (i :: IxFree k f)) (j :: IxFree k f) :: k Source #

Methods

ipure :: a -> f (Identity (IxFree k f)) a Source #

iap :: f i (a -> b) -> f j a -> f ((IxFree k f <> i) j) b Source #

Show1 [k] f => Show1 [k] (IxFree k f) Source # 

Methods

show1 :: Show a => f i a -> String Source #

Functor1 [k] f => Functor1 [k] (IxFree k f) Source # 

Methods

fmap1 :: (a -> b) -> f i a -> f i b Source #

Functor1 [k] f => Functor (IxFree k f i) Source # 

Methods

fmap :: (a -> b) -> IxFree k f i a -> IxFree k f i b #

(<$) :: a -> IxFree k f i b -> IxFree k f i a #

(Show1 [k] f, Show a) => Show (IxFree k f i a) Source # 

Methods

showsPrec :: Int -> IxFree k f i a -> ShowS #

show :: IxFree k f i a -> String #

showList :: [IxFree k f i a] -> ShowS #

(NFData1 [k] f, NFData a) => NFData (IxFree k f i a) Source # 

Methods

rnf :: IxFree k f i a -> () #

ToXML (IxFree Type DialNounF i Void) Source # 
ToXML (IxFree Type MessagingVerbsF i Void) Source # 
ToXML (IxFree Type VoiceVerbsF i Void) Source # 

iliftF :: forall f i a. (WitnessList i, Functor1 f) => f i a -> IxFree f i a Source #

Lift an indexed functor into IxFree

type family (a :: [k]) ++ (b :: [k]) :: [k] where ... Source #

Promoted list concatenation

Equations

'[] ++ bs = bs 
(a ': as) ++ bs = a ': (as ++ bs) 

XML

The classes here simplify working with the xml package.

data SomeNode Source #

Constructors

Node n => SomeNode n 

Instances

class ToXML a where Source #

Minimal complete definition

toXML

Methods

toXML :: a -> [Element] Source #

Instances

ToXML DialNoun Source # 

Methods

toXML :: DialNoun -> [Element] Source #

ToXML (ClientF i a) Source # 

Methods

toXML :: ClientF i a -> [Element] Source #

ToXML (ConferenceF i a) Source # 

Methods

toXML :: ConferenceF i a -> [Element] Source #

ToXML (NumberF i a) Source # 

Methods

toXML :: NumberF i a -> [Element] Source #

ToXML (QueueF i a) Source # 

Methods

toXML :: QueueF i a -> [Element] Source #

ToXML (DialNounF i a) Source # 

Methods

toXML :: DialNounF i a -> [Element] Source #

ToXML (SipF i a) Source # 

Methods

toXML :: SipF i a -> [Element] Source #

ToXML a => ToXML (DialF i a) Source # 

Methods

toXML :: DialF i a -> [Element] Source #

ToXML (EndF i a) Source # 

Methods

toXML :: EndF i a -> [Element] Source #

ToXML a => ToXML (EnqueueF i a) Source # 

Methods

toXML :: EnqueueF i a -> [Element] Source #

ToXML (HangupF i a) Source # 

Methods

toXML :: HangupF i a -> [Element] Source #

ToXML (LeaveF i a) Source # 

Methods

toXML :: LeaveF i a -> [Element] Source #

ToXML a => ToXML (MessageF i a) Source # 

Methods

toXML :: MessageF i a -> [Element] Source #

ToXML a => ToXML (PauseF i a) Source # 

Methods

toXML :: PauseF i a -> [Element] Source #

ToXML a => ToXML (PlayF i a) Source # 

Methods

toXML :: PlayF i a -> [Element] Source #

ToXML a => ToXML (RecordF i a) Source # 

Methods

toXML :: RecordF i a -> [Element] Source #

ToXML (RedirectF i a) Source # 

Methods

toXML :: RedirectF i a -> [Element] Source #

ToXML (RejectF i a) Source # 

Methods

toXML :: RejectF i a -> [Element] Source #

ToXML a => ToXML (SayF i a) Source # 

Methods

toXML :: SayF i a -> [Element] Source #

ToXML a => ToXML (MessagingVerbsF i a) Source # 

Methods

toXML :: MessagingVerbsF i a -> [Element] Source #

ToXML a => ToXML (VoiceVerbsF i a) Source # 

Methods

toXML :: VoiceVerbsF i a -> [Element] Source #

ToXML a => ToXML (GatherF i a) Source # 

Methods

toXML :: GatherF i a -> [Element] Source #

ToXML a => ToXML (SmsF i a) Source # 

Methods

toXML :: SmsF i a -> [Element] Source #

ToXML (IxFree Type DialNounF i Void) Source # 
ToXML (IxFree Type MessagingVerbsF i Void) Source # 
ToXML (IxFree Type VoiceVerbsF i Void) Source # 
(ToXML (f a), ToXML (g a)) => ToXML ((:+:) k f g a) Source # 

Methods

toXML :: (k :+: f) g a -> [Element] Source #

class ToElement a where Source #

Minimal complete definition

toElement

Methods

toElement :: a -> Element Source #

class ToAttrs a where Source #

Minimal complete definition

toAttrs

Methods

toAttrs :: a -> [Attr] Source #

makeAttr :: ToAttrValue b => String -> (a -> Maybe b) -> a -> Maybe Attr Source #

makeAttr' :: String -> (a -> Maybe b) -> (b -> String) -> a -> Maybe Attr Source #

makeAttrs :: a -> [a -> Maybe Attr] -> [Attr] Source #

makeElement :: Node t => String -> t -> [Attr] -> Element Source #

Orphan instances

ToSomeNode n => Node n Source # 

Methods

node :: QName -> n -> Element #