1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE DuplicateRecordFields #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE OverloadedStrings #-}
5 {-# LANGUAGE TypeFamilyDependencies #-}
6 module Language.RNC.Sym where
8 import Control.Applicative (Applicative(..), (<$>))
9 import Data.Default.Class (Default(..))
10 import Data.Foldable (Foldable,foldl',foldr)
11 import Data.Function (($),(.),id,flip)
13 import Data.Maybe (Maybe(..))
14 import Data.Text (Text)
15 import Text.Show (Show)
19 foldlApp :: (Default a, Foldable t) => t (a -> a) -> a
20 foldlApp = foldl' (flip ($)) def
21 foldrApp :: (Default a, Foldable t) => t (a -> a) -> a
22 foldrApp = foldr ($) def
27 -- ** Class 'Sym_Rule'
28 class Sym_Rule repr where
29 rule :: Show a => Text -> Rule (repr a)
32 -- * Type family 'Perm'
33 type family Perm (repr:: * -> *) = (r :: * -> *) | r -> repr
35 -- * Class 'Sym_Interleaved'
36 class Sym_Interleaved repr where
37 interleaved :: Perm repr a -> repr a
38 (<$$>) :: (a -> b) -> repr a -> Perm repr b
40 (<$?>) :: (a -> b) -> (a,repr a) -> Perm repr b
41 (<||>) :: Perm repr (a -> b) -> repr a -> Perm repr b
42 (<|?>) :: Perm repr (a -> b) -> (a,repr a) -> Perm repr b
44 (<$*>) :: ([a] -> b) -> repr a -> Perm repr b
45 (<|*>) :: Perm repr ([a] -> b) -> repr a -> Perm repr b
48 infixl 2 <$$>, <$?>, <$*>
49 infixl 1 <||>, <|?>, <|*>
56 , Sym_Interleaved repr
57 ) => Sym_RNC repr where
58 element :: XmlName -> repr a -> repr a
59 attribute :: XmlName -> repr a -> repr a
61 try :: repr a -> repr a
63 anyElem :: Show a => (XmlName -> repr a) -> repr a
69 (<|>) :: repr a -> repr a -> repr a
70 many :: repr a -> repr [a]
71 some :: repr a -> repr [a]
72 optional :: repr a -> repr (Maybe a)
73 option :: a -> repr a -> repr a
74 choice :: [repr a] -> repr a
75 intermany :: [repr a] -> repr [a]
76 intermany = many . choice . (try <$>)