1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE DuplicateRecordFields #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE TypeFamilyDependencies #-}
5 module Hdoc.RNC.Sym where
7 import Control.Applicative (Applicative(..), (<$>))
8 import Data.Function ((.),id)
10 import Data.Maybe (Maybe(..))
11 import Data.Text (Text)
12 import Text.Show (Show)
13 import qualified Data.Text.Lazy as TL
20 -- ** Class 'Sym_Rule'
21 class Sym_Rule repr where
22 rule :: Show a => Text -> Rule (repr a)
25 -- * Type family 'Perm'
26 type family Perm (repr:: * -> *) = (r :: * -> *) | r -> repr
28 -- * Class 'Sym_Interleaved'
29 class Sym_Interleaved repr where
30 interleaved :: Perm repr a -> repr a
31 (<$$>) :: (a -> b) -> repr a -> Perm repr b
33 (<$?>) :: (a -> b) -> (a,repr a) -> Perm repr b
34 (<||>) :: Perm repr (a -> b) -> repr a -> Perm repr b
35 (<|?>) :: Perm repr (a -> b) -> (a,repr a) -> Perm repr b
37 (<$*>) :: ([a] -> b) -> repr a -> Perm repr b
38 (<|*>) :: Perm repr ([a] -> b) -> repr a -> Perm repr b
41 infixl 2 <$$>, <$?>, <$*>
42 infixl 1 <||>, <|?>, <|*>
49 , Sym_Interleaved repr
50 ) => Sym_RNC repr where
51 element :: XmlName -> repr a -> repr a
52 attribute :: XmlName -> repr a -> repr a
53 comment :: repr TL.Text
54 try :: repr a -> repr a
57 anyElem :: Show a => (XmlName -> repr a) -> repr a
63 (<|>) :: repr a -> repr a -> repr a
64 many :: repr a -> repr [a]
65 -- TODO: maybe use Seq instead of []
66 some :: repr a -> repr [a]
67 optional :: repr a -> repr (Maybe a)
68 option :: a -> repr a -> repr a
69 choice :: [repr a] -> repr a
70 intermany :: [repr a] -> repr [a]
71 intermany = many . choice . (try <$>)