Copyright | (C) 2014-15 Mark Andrus Roberts |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Mark Andrus Roberts <markandrusroberts@gmail.com> |
Stability | provisional |
Safe Haskell | None |
Language | Haskell98 |
Text.XML.Twiml.Internal
Description
This module exports the machinery necessary to define TwiML in an extensible way.
- data (f :+: g) a
- class (Functor sub, Functor sup) => sub :<: sup where
- type family Elem t ts :: Bool
- type (∉) t ts = Elem t ts ~ False
- class Functor1 f where
- fmap1 :: (a -> b) -> f i a -> f i b
- class NFData1 f where
- class Show1 f where
- class Functor1 f => IxApplicative f where
- class IxApplicative m => IxMonad m where
- data IxFree f i a where
- iliftF :: forall f i a. (WitnessList i, Functor1 f) => f i a -> IxFree f i a
- type family a ++ b :: [k]
- data SomeNode = forall n . Node n => SomeNode n
- class ToSomeNode a where
- toSomeNode :: a -> SomeNode
- class ToXML a where
- class ToElement a where
- class ToAttrs a where
- class ToAttrValue a where
- toAttrValue :: a -> String
- makeAttr :: ToAttrValue b => String -> (a -> Maybe b) -> a -> Maybe Attr
- makeAttr' :: String -> (a -> Maybe b) -> (b -> String) -> a -> Maybe Attr
- makeAttrs :: a -> [a -> Maybe Attr] -> [Attr]
- makeElement :: Node t => String -> t -> [Attr] -> Element
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
Instances
(Functor f, Functor g, Functor h, (:<:) f g) => f :<: ((:+:) * h g) Source | |
(Functor f, Functor g) => f :<: ((:+:) * f g) Source | |
(Functor f, Functor g) => Functor ((:+:) * f g) Source | |
(Eq (f a), Eq (g a)) => Eq ((:+:) k f g a) Source | |
(Data a, Data (f a), Data (g a), Typeable (* -> *) f, Typeable (* -> *) g) => Data ((:+:) * f g a) Source | |
(Ord (f a), Ord (g a)) => Ord ((:+:) k f g a) Source | |
(Read (f a), Read (g a)) => Read ((:+:) k f g a) Source | |
(Show (f a), Show (g a)) => Show ((:+:) k f g a) Source | |
Generic ((:+:) k f g a) Source | |
(NFData (f a), NFData (g a)) => NFData ((:+:) k f g a) Source | |
(ToXML (f a), ToXML (g a)) => ToXML ((:+:) k f g a) Source | |
type Rep ((:+:) k f g a) Source |
class (Functor sub, Functor sup) => sub :<: sup where Source
Instances
Functor f => f :<: f Source | |
(Functor f, Functor g, Functor h, (:<:) f g) => f :<: ((:+:) * h g) Source | |
(Functor f, Functor g) => f :<: ((:+:) * f g) Source | |
(:<:) (f i) ((:+:) * (ClientF i) ((:+:) * (ConferenceF i) ((:+:) * (NumberF i) ((:+:) * (QueueF i) (SipF i))))) => (f i) :<: (DialNounF i) Source | |
(:<:) (f i) ((:+:) * (MessageF i) ((:+:) * (RedirectF i) ((:+:) * (SmsF i) (EndF i)))) => (f i) :<: (MessagingVerbsF i) Source | |
(:<:) (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 |
Elem (∉)
type family Elem t ts :: Bool 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
.
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.
Instances
Functor1 [*] ClientF Source | |
Functor1 [*] ConferenceF Source | |
Functor1 [*] NumberF Source | |
Functor1 [*] QueueF Source | |
Functor1 [*] DialNounF Source | |
Functor1 [*] SipF Source | |
Functor1 [*] DialF Source | |
Functor1 [*] EndF Source | |
Functor1 [*] EnqueueF Source | |
Functor1 [*] HangupF Source | |
Functor1 [*] LeaveF Source | |
Functor1 [*] MessageF Source | |
Functor1 [*] PauseF Source | |
Functor1 [*] PlayF Source | |
Functor1 [*] RecordF Source | |
Functor1 [*] RedirectF Source | |
Functor1 [*] RejectF Source | |
Functor1 [*] SayF Source | |
Functor1 [*] MessagingVerbsF Source | |
Functor1 [*] VoiceVerbsF Source | |
Functor1 [*] GatherF Source | |
Functor1 [*] SmsF Source | |
Functor1 [k] f => Functor1 [k] (IxFree k f) 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 -> fIdentity
a pure =ipure
(<*>) ::IxApplicative
f => f i (a -> b) -> f j a -> f (i<>
j) b (<*>) =iap
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 |
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 -> mIdentity
a return =ipure
This is the technique employed by the Text.XML.Twiml.Syntax module.
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 | |
(Functor1 [k] m, IxApplicative [k] (IxFree k m)) => IxMonad [k] (IxFree k m) Source | |
Functor1 [k] f => IxApplicative [k] (IxFree k f) Source | |
Show1 [k] f => Show1 [k] (IxFree k f) Source | |
Functor1 [k] f => Functor1 [k] (IxFree k f) Source | |
Functor1 [k] f => Functor (IxFree k f i) Source | |
(Show1 [k] f, Show a) => Show (IxFree k f i a) Source | |
(NFData1 [k] f, NFData a) => NFData (IxFree k f i a) Source | |
ToXML (IxFree * DialNounF i Void) Source | |
ToXML (IxFree * MessagingVerbsF i Void) Source | |
ToXML (IxFree * 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
XML
The classes here simplify working with the xml package.
Instances
ToXML DialNoun Source | |
ToXML (ClientF i a) Source | |
ToXML (ConferenceF i a) Source | |
ToXML (NumberF i a) Source | |
ToXML (QueueF i a) Source | |
ToXML a => ToXML (DialNounF i a) Source | |
ToXML (SipF i a) Source | |
ToXML a => ToXML (DialF i a) Source | |
ToXML (EndF i a) Source | |
ToXML a => ToXML (EnqueueF i a) Source | |
ToXML (HangupF i a) Source | |
ToXML (LeaveF i a) Source | |
ToXML a => ToXML (MessageF i a) Source | |
ToXML a => ToXML (PauseF i a) Source | |
ToXML a => ToXML (PlayF i a) Source | |
ToXML a => ToXML (RecordF i a) Source | |
ToXML (RedirectF i a) Source | |
ToXML (RejectF i a) Source | |
ToXML a => ToXML (SayF i a) Source | |
ToXML a => ToXML (MessagingVerbsF i a) Source | |
ToXML a => ToXML (VoiceVerbsF i a) Source | |
ToXML a => ToXML (GatherF i a) Source | |
ToXML a => ToXML (SmsF i a) Source | |
ToXML (IxFree * DialNounF i Void) Source | |
ToXML (IxFree * MessagingVerbsF i Void) Source | |
ToXML (IxFree * VoiceVerbsF i Void) Source | |
(ToXML (f a), ToXML (g a)) => ToXML ((:+:) k f g a) Source |
Instances
class ToAttrValue a where Source
toAttrValue
transforms a data type into a String
that can be set as the
value of an attribute.
Methods
toAttrValue :: a -> String Source
Instances