| Copyright | (C) 2018 Mark Andrus Roberts |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Mark Andrus Roberts <markandrusroberts@gmail.com> |
| Stability | provisional |
| Safe Haskell | Safe |
| 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 :: k) (ts :: [k]) :: Bool where ...
- type (∉) t ts = Elem t ts ~ False
- class Functor1 f where
- class NFData1 f where
- class Show1 f where
- class Functor1 f => IxApplicative (f :: k -> * -> *) where
- class IxApplicative m => IxMonad (m :: k -> * -> *) where
- data IxFree f (i :: [k]) a where
- iliftF :: forall f i a. (WitnessList i, Functor1 f) => f i a -> IxFree f i a
- type family (a :: [k]) ++ (b :: [k]) :: [k] where ...
- data SomeNode = Node n => SomeNode n
- class ToSomeNode a where
- class ToXML a where
- class ToElement a where
- class ToAttrs a where
- class ToAttrValue a where
- 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) => f :<: ((:+:) * f g) Source # | |
| (Functor f, Functor g, Functor h, (:<:) f g) => f :<: ((:+:) * h g) Source # | |
| (Functor g, Functor f) => Functor ((:+:) * f g) Source # | |
| (Eq (g a), Eq (f 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 (g a), Ord (f a)) => Ord ((:+:) k f g a) Source # | |
| (Read (g a), Read (f a)) => Read ((:+:) k f g a) Source # | |
| (Show (g a), Show (f a)) => Show ((:+:) k f g a) Source # | |
| Generic ((:+:) k f g a) Source # | |
| (NFData (g a), NFData (f 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) => f :<: ((:+:) * f g) Source # | |
| (Functor f, Functor g, Functor h, (:<:) f g) => f :<: ((:+:) * h g) Source # | |
| (Functor (f i), (:<:) (f i) ((:+:) * (ClientF i) ((:+:) * (ConferenceF i) ((:+:) * (NumberF i) ((:+:) * (QueueF i) (SipF i)))))) => (f i) :<: (DialNounF i) Source # | |
| (Functor (f i), (:<:) (f i) ((:+:) * (MessageF i) ((:+:) * (RedirectF i) ((:+:) * (SmsF i) (EndF i))))) => (f i) :<: (MessagingVerbsF i) 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 # | |
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.
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
Instances
| Functor1 [Type] ClientF Source # | |
| Functor1 [Type] ConferenceF Source # | |
| Functor1 [Type] NumberF Source # | |
| Functor1 [Type] QueueF Source # | |
| Functor1 [Type] DialNounF Source # | |
| Functor1 [Type] SipF Source # | |
| Functor1 [Type] DialF Source # | |
| Functor1 [Type] EndF Source # | |
| Functor1 [Type] EnqueueF Source # | |
| Functor1 [Type] HangupF Source # | |
| Functor1 [Type] LeaveF Source # | |
| Functor1 [Type] MessageF Source # | |
| Functor1 [Type] PauseF Source # | |
| Functor1 [Type] PlayF Source # | |
| Functor1 [Type] RecordF Source # | |
| Functor1 [Type] RedirectF Source # | |
| Functor1 [Type] RejectF Source # | |
| Functor1 [Type] SayF Source # | |
| Functor1 [Type] MessagingVerbsF Source # | |
| Functor1 [Type] VoiceVerbsF Source # | |
| Functor1 [Type] GatherF Source # | |
| Functor1 [Type] SmsF Source # | |
| Functor1 [k] f => Functor1 [k] (IxFree k f) Source # | |
Minimal complete definition
Applicative
class Functor1 f => IxApplicative (f :: k -> * -> *) 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 ::IxApplicativef -> a -> fIdentitya pure =ipure(<*>) ::IxApplicativef => 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 :: k -> * -> *) 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
Free
data IxFree f (i :: [k]) 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 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
XML
The classes here simplify working with the xml package.
class ToSomeNode a where Source #
Minimal complete definition
Methods
toSomeNode :: a -> SomeNode Source #
Instances
| ToSomeNode () Source # | |
| ToSomeNode String Source # | |
| ToSomeNode URL Source # | |
| ToSomeNode DialNoun Source # | |
| ToSomeNode a => ToSomeNode (Maybe a) Source # | |
Minimal complete definition
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 (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 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 # | |
class ToAttrs a where Source #
Minimal complete definition
Instances
class ToAttrValue a where Source #
toAttrValue transforms a data type into a String that can be set as the
value of an attribute.
Minimal complete definition
Methods
toAttrValue :: a -> String Source #
Instances
Orphan instances
| ToSomeNode n => Node n Source # | |