{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE CPP #-}
module Text.Hamlet.XMLParse
    ( Result (..)
    , Content (..)
    , Doc (..)
    , parseDoc
    , Binding (..)
    , DataConstr (..)
    , Module (..)
    )
    where

import Text.Shakespeare.Base
import Control.Applicative ((<$>), Applicative (..))
import Control.Monad
import Data.Char (isUpper)
import Data.Data
import Text.ParserCombinators.Parsec hiding (Line)

data Result v = Error String | Ok v
    deriving (Int -> Result v -> ShowS
[Result v] -> ShowS
Result v -> String
(Int -> Result v -> ShowS)
-> (Result v -> String) -> ([Result v] -> ShowS) -> Show (Result v)
forall v. Show v => Int -> Result v -> ShowS
forall v. Show v => [Result v] -> ShowS
forall v. Show v => Result v -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall v. Show v => Int -> Result v -> ShowS
showsPrec :: Int -> Result v -> ShowS
$cshow :: forall v. Show v => Result v -> String
show :: Result v -> String
$cshowList :: forall v. Show v => [Result v] -> ShowS
showList :: [Result v] -> ShowS
Show, Result v -> Result v -> Bool
(Result v -> Result v -> Bool)
-> (Result v -> Result v -> Bool) -> Eq (Result v)
forall v. Eq v => Result v -> Result v -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall v. Eq v => Result v -> Result v -> Bool
== :: Result v -> Result v -> Bool
$c/= :: forall v. Eq v => Result v -> Result v -> Bool
/= :: Result v -> Result v -> Bool
Eq, ReadPrec [Result v]
ReadPrec (Result v)
Int -> ReadS (Result v)
ReadS [Result v]
(Int -> ReadS (Result v))
-> ReadS [Result v]
-> ReadPrec (Result v)
-> ReadPrec [Result v]
-> Read (Result v)
forall v. Read v => ReadPrec [Result v]
forall v. Read v => ReadPrec (Result v)
forall v. Read v => Int -> ReadS (Result v)
forall v. Read v => ReadS [Result v]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall v. Read v => Int -> ReadS (Result v)
readsPrec :: Int -> ReadS (Result v)
$creadList :: forall v. Read v => ReadS [Result v]
readList :: ReadS [Result v]
$creadPrec :: forall v. Read v => ReadPrec (Result v)
readPrec :: ReadPrec (Result v)
$creadListPrec :: forall v. Read v => ReadPrec [Result v]
readListPrec :: ReadPrec [Result v]
Read, Typeable (Result v)
Typeable (Result v) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Result v -> c (Result v))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Result v))
-> (Result v -> Constr)
-> (Result v -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Result v)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Result v)))
-> ((forall b. Data b => b -> b) -> Result v -> Result v)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Result v -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Result v -> r)
-> (forall u. (forall d. Data d => d -> u) -> Result v -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Result v -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Result v -> m (Result v))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Result v -> m (Result v))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Result v -> m (Result v))
-> Data (Result v)
Result v -> Constr
Result v -> DataType
(forall b. Data b => b -> b) -> Result v -> Result v
forall v. Data v => Typeable (Result v)
forall v. Data v => Result v -> Constr
forall v. Data v => Result v -> DataType
forall v.
Data v =>
(forall b. Data b => b -> b) -> Result v -> Result v
forall v u.
Data v =>
Int -> (forall d. Data d => d -> u) -> Result v -> u
forall v u.
Data v =>
(forall d. Data d => d -> u) -> Result v -> [u]
forall v r r'.
Data v =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
forall v r r'.
Data v =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
forall v (m :: * -> *).
(Data v, Monad m) =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
forall v (m :: * -> *).
(Data v, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
forall v (c :: * -> *).
Data v =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Result v)
forall v (c :: * -> *).
Data v =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Result v -> c (Result v)
forall v (t :: * -> *) (c :: * -> *).
(Data v, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Result v))
forall v (t :: * -> * -> *) (c :: * -> *).
(Data v, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Result v))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Result v -> u
forall u. (forall d. Data d => d -> u) -> Result v -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Result v)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Result v -> c (Result v)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Result v))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Result v))
$cgfoldl :: forall v (c :: * -> *).
Data v =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Result v -> c (Result v)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Result v -> c (Result v)
$cgunfold :: forall v (c :: * -> *).
Data v =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Result v)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Result v)
$ctoConstr :: forall v. Data v => Result v -> Constr
toConstr :: Result v -> Constr
$cdataTypeOf :: forall v. Data v => Result v -> DataType
dataTypeOf :: Result v -> DataType
$cdataCast1 :: forall v (t :: * -> *) (c :: * -> *).
(Data v, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Result v))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Result v))
$cdataCast2 :: forall v (t :: * -> * -> *) (c :: * -> *).
(Data v, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Result v))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Result v))
$cgmapT :: forall v.
Data v =>
(forall b. Data b => b -> b) -> Result v -> Result v
gmapT :: (forall b. Data b => b -> b) -> Result v -> Result v
$cgmapQl :: forall v r r'.
Data v =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
$cgmapQr :: forall v r r'.
Data v =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Result v -> r
$cgmapQ :: forall v u.
Data v =>
(forall d. Data d => d -> u) -> Result v -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Result v -> [u]
$cgmapQi :: forall v u.
Data v =>
Int -> (forall d. Data d => d -> u) -> Result v -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Result v -> u
$cgmapM :: forall v (m :: * -> *).
(Data v, Monad m) =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
$cgmapMp :: forall v (m :: * -> *).
(Data v, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
$cgmapMo :: forall v (m :: * -> *).
(Data v, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Result v -> m (Result v)
Data, Typeable)
instance Monad Result where
    return :: forall a. a -> Result a
return = a -> Result a
forall a. a -> Result a
Ok
    Error String
s >>= :: forall a b. Result a -> (a -> Result b) -> Result b
>>= a -> Result b
_ = String -> Result b
forall v. String -> Result v
Error String
s
    Ok a
v >>= a -> Result b
f = a -> Result b
f a
v
#if MIN_VERSION_base(4,13,0)
instance MonadFail Result where
#endif
    fail :: forall v. String -> Result v
fail = String -> Result a
forall v. String -> Result v
Error
instance Functor Result where
    fmap :: forall a b. (a -> b) -> Result a -> Result b
fmap = (a -> b) -> Result a -> Result b
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM
instance Applicative Result where
    pure :: forall a. a -> Result a
pure = a -> Result a
forall a. a -> Result a
forall (m :: * -> *) a. Monad m => a -> m a
return
    <*> :: forall a b. Result (a -> b) -> Result a -> Result b
(<*>) = Result (a -> b) -> Result a -> Result b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap

data Content = ContentRaw String
             | ContentVar Deref
             | ContentEmbed Deref
    deriving (Int -> Content -> ShowS
[Content] -> ShowS
Content -> String
(Int -> Content -> ShowS)
-> (Content -> String) -> ([Content] -> ShowS) -> Show Content
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Content -> ShowS
showsPrec :: Int -> Content -> ShowS
$cshow :: Content -> String
show :: Content -> String
$cshowList :: [Content] -> ShowS
showList :: [Content] -> ShowS
Show, Content -> Content -> Bool
(Content -> Content -> Bool)
-> (Content -> Content -> Bool) -> Eq Content
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Content -> Content -> Bool
== :: Content -> Content -> Bool
$c/= :: Content -> Content -> Bool
/= :: Content -> Content -> Bool
Eq, ReadPrec [Content]
ReadPrec Content
Int -> ReadS Content
ReadS [Content]
(Int -> ReadS Content)
-> ReadS [Content]
-> ReadPrec Content
-> ReadPrec [Content]
-> Read Content
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Content
readsPrec :: Int -> ReadS Content
$creadList :: ReadS [Content]
readList :: ReadS [Content]
$creadPrec :: ReadPrec Content
readPrec :: ReadPrec Content
$creadListPrec :: ReadPrec [Content]
readListPrec :: ReadPrec [Content]
Read, Typeable Content
Typeable Content =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Content -> c Content)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Content)
-> (Content -> Constr)
-> (Content -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Content))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content))
-> ((forall b. Data b => b -> b) -> Content -> Content)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Content -> r)
-> (forall u. (forall d. Data d => d -> u) -> Content -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Content -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Content -> m Content)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Content -> m Content)
-> Data Content
Content -> Constr
Content -> DataType
(forall b. Data b => b -> b) -> Content -> Content
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Content -> u
forall u. (forall d. Data d => d -> u) -> Content -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Content -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Content -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Content -> m Content
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Content -> m Content
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Content
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Content -> c Content
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Content)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Content -> c Content
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Content -> c Content
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Content
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Content
$ctoConstr :: Content -> Constr
toConstr :: Content -> Constr
$cdataTypeOf :: Content -> DataType
dataTypeOf :: Content -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Content)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Content)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content)
$cgmapT :: (forall b. Data b => b -> b) -> Content -> Content
gmapT :: (forall b. Data b => b -> b) -> Content -> Content
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Content -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Content -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Content -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Content -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Content -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Content -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Content -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Content -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Content -> m Content
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Content -> m Content
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Content -> m Content
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Content -> m Content
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Content -> m Content
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Content -> m Content
Data, Typeable)

data Line = LineForall Deref Binding
          | LineIf Deref
          | LineElseIf Deref
          | LineElse
          | LineWith [(Deref, Binding)]
          | LineMaybe Deref Binding
          | LineNothing
          | LineCase Deref
          | LineOf Binding
          | LineTag
            { Line -> String
_lineTagName :: String
            , Line -> [(Maybe Deref, String, [Content])]
_lineAttr :: [(Maybe Deref, String, [Content])]
            , Line -> [Content]
_lineContent :: [Content]
            , Line -> [Deref]
_lineAttrs :: [Deref]
            }
          | LineContent [Content]
    deriving (Line -> Line -> Bool
(Line -> Line -> Bool) -> (Line -> Line -> Bool) -> Eq Line
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Line -> Line -> Bool
== :: Line -> Line -> Bool
$c/= :: Line -> Line -> Bool
/= :: Line -> Line -> Bool
Eq, Int -> Line -> ShowS
[Line] -> ShowS
Line -> String
(Int -> Line -> ShowS)
-> (Line -> String) -> ([Line] -> ShowS) -> Show Line
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Line -> ShowS
showsPrec :: Int -> Line -> ShowS
$cshow :: Line -> String
show :: Line -> String
$cshowList :: [Line] -> ShowS
showList :: [Line] -> ShowS
Show, ReadPrec [Line]
ReadPrec Line
Int -> ReadS Line
ReadS [Line]
(Int -> ReadS Line)
-> ReadS [Line] -> ReadPrec Line -> ReadPrec [Line] -> Read Line
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Line
readsPrec :: Int -> ReadS Line
$creadList :: ReadS [Line]
readList :: ReadS [Line]
$creadPrec :: ReadPrec Line
readPrec :: ReadPrec Line
$creadListPrec :: ReadPrec [Line]
readListPrec :: ReadPrec [Line]
Read)

parseLines :: String -> Result [(Int, Line)]
parseLines :: String -> Result [(Int, Line)]
parseLines String
s =
    case Parsec String () [(Int, Line)]
-> String -> String -> Either ParseError [(Int, Line)]
forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
parse (ParsecT String () Identity (Int, Line)
-> Parsec String () [(Int, Line)]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT String () Identity (Int, Line)
parseLine) String
s String
s of
        Left ParseError
e -> String -> Result [(Int, Line)]
forall v. String -> Result v
Error (String -> Result [(Int, Line)]) -> String -> Result [(Int, Line)]
forall a b. (a -> b) -> a -> b
$ ParseError -> String
forall a. Show a => a -> String
show ParseError
e
        Right [(Int, Line)]
x -> [(Int, Line)] -> Result [(Int, Line)]
forall a. a -> Result a
Ok [(Int, Line)]
x

parseLine :: Parser (Int, Line)
parseLine :: ParsecT String () Identity (Int, Line)
parseLine = do
    Int
ss <- ([Int] -> Int)
-> ParsecT String () Identity [Int]
-> ParsecT String () Identity Int
forall a b.
(a -> b)
-> ParsecT String () Identity a -> ParsecT String () Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Int] -> Int
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (ParsecT String () Identity [Int]
 -> ParsecT String () Identity Int)
-> ParsecT String () Identity [Int]
-> ParsecT String () Identity Int
forall a b. (a -> b) -> a -> b
$ ParsecT String () Identity Int -> ParsecT String () Identity [Int]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ((Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
' ' ParsecT String () Identity Char
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Int -> ParsecT String () Identity Int
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
1) ParsecT String () Identity Int
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
                           (Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\t' ParsecT String () Identity Char
-> ParsecT String () Identity Int -> ParsecT String () Identity Int
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> String -> ParsecT String () Identity Int
forall a. String -> ParsecT String () Identity a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Tabs are not allowed in Hamlet indentation"))
    Line
x <- ParsecT String () Identity Line
forall {st}. ParsecT String st Identity Line
comment ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
forall {st}. ParsecT String st Identity Line
htmlComment ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
forall {st}. ParsecT String st Identity Line
backslash ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlIf ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlElseIf ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         (GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$else") GenParser Char () String
-> GenParser Char () String -> GenParser Char () String
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> GenParser Char () String
spaceTabs GenParser Char () String
-> ParsecT String () Identity () -> ParsecT String () Identity ()
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol ParsecT String () Identity ()
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Line
LineElse) ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlMaybe ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         (GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$nothing") GenParser Char () String
-> GenParser Char () String -> GenParser Char () String
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> GenParser Char () String
spaceTabs GenParser Char () String
-> ParsecT String () Identity () -> ParsecT String () Identity ()
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol ParsecT String () Identity ()
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Line
LineNothing) ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlForall ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlWith ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlCase ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
controlOf ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
forall {st}. ParsecT String st Identity Line
angle ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         ParsecT String () Identity Line
forall {u} {b}. ParsecT String u Identity b
invalidDollar ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         (ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol' ParsecT String () Identity ()
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Content] -> Line
LineContent [])) ParsecT String () Identity Line
-> ParsecT String () Identity Line
-> ParsecT String () Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
         (do
            [Content]
cs <- ContentRule -> ParsecT String () Identity [Content]
forall {u}. ContentRule -> ParsecT String u Identity [Content]
content ContentRule
InContent
            Bool
isEof <- (ParsecT String () Identity ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParsecT String () Identity ()
-> ParsecT String () Identity Bool
-> ParsecT String () Identity Bool
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Bool -> ParsecT String () Identity Bool
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True) ParsecT String () Identity Bool
-> ParsecT String () Identity Bool
-> ParsecT String () Identity Bool
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Bool -> ParsecT String () Identity Bool
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
            if [Content] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Content]
cs Bool -> Bool -> Bool
&& Int
ss Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 Bool -> Bool -> Bool
&& Bool
isEof
                then String -> ParsecT String () Identity Line
forall a. String -> ParsecT String () Identity a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"End of Hamlet template"
                else Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ [Content] -> Line
LineContent [Content]
cs)
    (Int, Line) -> ParsecT String () Identity (Int, Line)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
ss, Line
x)
  where
    eol' :: ParsecT String u Identity ()
eol' = (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\n' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> ParsecT String u Identity ()
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ()) ParsecT String u Identity ()
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (String -> ParsecT String u Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"\r\n" ParsecT String u Identity String
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> ParsecT String u Identity ()
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
    eol :: ParsecT String u Identity ()
eol = ParsecT String u Identity ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParsecT String u Identity ()
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
eol'
    invalidDollar :: ParsecT String u Identity b
invalidDollar = do
        Char
_ <- Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'$'
        String -> ParsecT String u Identity b
forall a. String -> ParsecT String u Identity a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Received a command I did not understand. If you wanted a literal $, start the line with a backslash."
    comment :: ParsecT String st Identity Line
comment = do
        String
_ <- GenParser Char st String -> GenParser Char st String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char st String -> GenParser Char st String)
-> GenParser Char st String -> GenParser Char st String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$#"
        String
_ <- ParsecT String st Identity Char -> GenParser Char st String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String st Identity Char -> GenParser Char st String)
-> ParsecT String st Identity Char -> GenParser Char st String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"\r\n"
        ParsecT String st Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String st Identity Line
forall a. a -> ParsecT String st Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String st Identity Line)
-> Line -> ParsecT String st Identity Line
forall a b. (a -> b) -> a -> b
$ [Content] -> Line
LineContent []
    htmlComment :: ParsecT String st Identity Line
htmlComment = do
        String
_ <- GenParser Char st String -> GenParser Char st String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char st String -> GenParser Char st String)
-> GenParser Char st String -> GenParser Char st String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"<!--"
        String
_ <- ParsecT String st Identity Char
-> GenParser Char st String -> GenParser Char st String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar (GenParser Char st String -> GenParser Char st String)
-> GenParser Char st String -> GenParser Char st String
forall a b. (a -> b) -> a -> b
$ GenParser Char st String -> GenParser Char st String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char st String -> GenParser Char st String)
-> GenParser Char st String -> GenParser Char st String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char st String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"-->"
        [String]
x <- GenParser Char st String -> ParsecT String st Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many GenParser Char st String
forall {u}. ParsecT String u Identity String
nonComments
        ParsecT String st Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String st Identity Line
forall a. a -> ParsecT String st Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String st Identity Line)
-> Line -> ParsecT String st Identity Line
forall a b. (a -> b) -> a -> b
$ [Content] -> Line
LineContent [String -> Content
ContentRaw (String -> Content) -> String -> Content
forall a b. (a -> b) -> a -> b
$ [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
x] -- FIXME handle variables?
    nonComments :: ParsecT String u Identity String
nonComments = (ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT String u Identity Char
 -> ParsecT String u Identity String)
-> ParsecT String u Identity Char
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"\r\n<") ParsecT String u Identity String
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (do
        Char
_ <- Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'<'
        (do
            String
_ <- ParsecT String u Identity String
-> ParsecT String u Identity String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT String u Identity String
 -> ParsecT String u Identity String)
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"!--"
            String
_ <- ParsecT String u Identity Char
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT String u Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar (ParsecT String u Identity String
 -> ParsecT String u Identity String)
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ ParsecT String u Identity String
-> ParsecT String u Identity String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (ParsecT String u Identity String
 -> ParsecT String u Identity String)
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"-->"
            String -> ParsecT String u Identity String
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return String
"") ParsecT String u Identity String
-> ParsecT String u Identity String
-> ParsecT String u Identity String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> String -> ParsecT String u Identity String
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return String
"<")
    backslash :: ParsecT String u Identity Line
backslash = do
        Char
_ <- Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\\'
        (ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
eol ParsecT String u Identity ()
-> ParsecT String u Identity Line -> ParsecT String u Identity Line
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Line -> ParsecT String u Identity Line
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Content] -> Line
LineContent [String -> Content
ContentRaw String
"\n"]))
            ParsecT String u Identity Line
-> ParsecT String u Identity Line -> ParsecT String u Identity Line
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ([Content] -> Line
LineContent ([Content] -> Line)
-> ParsecT String u Identity [Content]
-> ParsecT String u Identity Line
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ContentRule -> ParsecT String u Identity [Content]
forall {u}. ContentRule -> ParsecT String u Identity [Content]
content ContentRule
InContent)
    controlIf :: ParsecT String () Identity Line
controlIf = do
        String
_ <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$if"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Deref
x <- UserParser () Deref
forall a. UserParser a Deref
parseDeref
        String
_ <- GenParser Char () String
spaceTabs
        ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ Deref -> Line
LineIf Deref
x
    controlElseIf :: ParsecT String () Identity Line
controlElseIf = do
        String
_ <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$elseif"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Deref
x <- UserParser () Deref
forall a. UserParser a Deref
parseDeref
        String
_ <- GenParser Char () String
spaceTabs
        ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ Deref -> Line
LineElseIf Deref
x
    binding :: ParsecT String () Identity (Deref, Binding)
binding = do
        Binding
y <- Parser Binding
identPattern
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        String
_ <- String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"<-"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Deref
x <- UserParser () Deref
forall a. UserParser a Deref
parseDeref
        String
_ <- GenParser Char () String
spaceTabs
        (Deref, Binding) -> ParsecT String () Identity (Deref, Binding)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Deref
x,Binding
y)
    bindingSep :: GenParser Char () String
bindingSep = Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',' ParsecT String () Identity Char
-> GenParser Char () String -> GenParser Char () String
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> GenParser Char () String
spaceTabs
    controlMaybe :: ParsecT String () Identity Line
controlMaybe = do
        String
_ <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$maybe"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        (Deref
x,Binding
y) <- ParsecT String () Identity (Deref, Binding)
binding
        ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ Deref -> Binding -> Line
LineMaybe Deref
x Binding
y
    controlForall :: ParsecT String () Identity Line
controlForall = do
        String
_ <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$forall"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        (Deref
x,Binding
y) <- ParsecT String () Identity (Deref, Binding)
binding
        ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ Deref -> Binding -> Line
LineForall Deref
x Binding
y
    controlWith :: ParsecT String () Identity Line
controlWith = do
        String
_ <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$with"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        [[(Deref, Binding)]]
bindings <- (ParsecT String () Identity (Deref, Binding)
binding ParsecT String () Identity (Deref, Binding)
-> GenParser Char () String
-> ParsecT String () Identity [(Deref, Binding)]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
`sepBy` GenParser Char () String
bindingSep) ParsecT String () Identity [(Deref, Binding)]
-> ParsecT String () Identity ()
-> ParsecT String () Identity [[(Deref, Binding)]]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
`endBy` ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ [(Deref, Binding)] -> Line
LineWith ([(Deref, Binding)] -> Line) -> [(Deref, Binding)] -> Line
forall a b. (a -> b) -> a -> b
$ [[(Deref, Binding)]] -> [(Deref, Binding)]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[(Deref, Binding)]]
bindings -- concat because endBy returns a [[(Deref,Ident)]]
    controlCase :: ParsecT String () Identity Line
controlCase = do
        String
_ <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$case"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Deref
x <- UserParser () Deref
forall a. UserParser a Deref
parseDeref
        String
_ <- GenParser Char () String
spaceTabs
        ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ Deref -> Line
LineCase Deref
x
    controlOf :: ParsecT String () Identity Line
controlOf = do
        String
_   <- GenParser Char () String -> GenParser Char () String
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () String -> GenParser Char () String)
-> GenParser Char () String -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> GenParser Char () String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"$of"
        ParsecT String () Identity ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
        Binding
x <- Parser Binding
identPattern
        String
_   <- GenParser Char () String
spaceTabs
        ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
eol
        Line -> ParsecT String () Identity Line
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String () Identity Line)
-> Line -> ParsecT String () Identity Line
forall a b. (a -> b) -> a -> b
$ Binding -> Line
LineOf Binding
x
    content :: ContentRule -> ParsecT String u Identity [Content]
content ContentRule
cr = do
        [Content]
x <- ParsecT String u Identity Content
-> ParsecT String u Identity [Content]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String u Identity Content
 -> ParsecT String u Identity [Content])
-> ParsecT String u Identity Content
-> ParsecT String u Identity [Content]
forall a b. (a -> b) -> a -> b
$ ContentRule -> ParsecT String u Identity Content
forall {u}. ContentRule -> ParsecT String u Identity Content
content' ContentRule
cr
        case ContentRule
cr of
            ContentRule
InQuotes -> ParsecT String u Identity Char -> ParsecT String u Identity ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ParsecT String u Identity Char -> ParsecT String u Identity ())
-> ParsecT String u Identity Char -> ParsecT String u Identity ()
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'"'
            ContentRule
NotInQuotes -> () -> ParsecT String u Identity ()
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
            ContentRule
NotInQuotesAttr -> () -> ParsecT String u Identity ()
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
            ContentRule
InContent -> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
eol
        [Content] -> ParsecT String u Identity [Content]
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Content] -> ParsecT String u Identity [Content])
-> [Content] -> ParsecT String u Identity [Content]
forall a b. (a -> b) -> a -> b
$ [Content] -> [Content]
cc [Content]
x
      where
        cc :: [Content] -> [Content]
cc [] = []
        cc (ContentRaw String
a:ContentRaw String
b:[Content]
c) = [Content] -> [Content]
cc ([Content] -> [Content]) -> [Content] -> [Content]
forall a b. (a -> b) -> a -> b
$ String -> Content
ContentRaw (String
a String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
b) Content -> [Content] -> [Content]
forall a. a -> [a] -> [a]
: [Content]
c
        cc (Content
a:[Content]
b) = Content
a Content -> [Content] -> [Content]
forall a. a -> [a] -> [a]
: [Content] -> [Content]
cc [Content]
b
    content' :: ContentRule -> ParsecT String u Identity Content
content' ContentRule
cr =     ContentRule -> ParsecT String u Identity Content
forall {u}. ContentRule -> ParsecT String u Identity Content
contentHash ContentRule
cr
                  ParsecT String u Identity Content
-> ParsecT String u Identity Content
-> ParsecT String u Identity Content
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT String u Identity Content
forall {a}. ParsecT String a Identity Content
contentCaret
                  ParsecT String u Identity Content
-> ParsecT String u Identity Content
-> ParsecT String u Identity Content
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ContentRule -> ParsecT String u Identity Content
forall {s} {m :: * -> *} {u}.
Stream s m Char =>
ContentRule -> ParsecT s u m Content
contentReg ContentRule
cr
    contentHash :: ContentRule -> ParsecT String a Identity Content
contentHash ContentRule
cr = do
        Either String Deref
x <- UserParser a (Either String Deref)
forall a. UserParser a (Either String Deref)
parseHash
        case Either String Deref
x of
            Left String
"#" -> case ContentRule
cr of
                          ContentRule
NotInQuotes -> String -> ParsecT String a Identity Content
forall a. String -> ParsecT String a Identity a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Expected hash at end of line, got Id"
                          ContentRule
_ -> Content -> ParsecT String a Identity Content
forall a. a -> ParsecT String a Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Content -> ParsecT String a Identity Content)
-> Content -> ParsecT String a Identity Content
forall a b. (a -> b) -> a -> b
$ String -> Content
ContentRaw String
"#"
            Left String
str -> Content -> ParsecT String a Identity Content
forall a. a -> ParsecT String a Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Content -> ParsecT String a Identity Content)
-> Content -> ParsecT String a Identity Content
forall a b. (a -> b) -> a -> b
$ String -> Content
ContentRaw String
str
            Right Deref
deref -> Content -> ParsecT String a Identity Content
forall a. a -> ParsecT String a Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Content -> ParsecT String a Identity Content)
-> Content -> ParsecT String a Identity Content
forall a b. (a -> b) -> a -> b
$ Deref -> Content
ContentVar Deref
deref
    contentCaret :: ParsecT String a Identity Content
contentCaret = do
        Either String Deref
x <- UserParser a (Either String Deref)
forall a. UserParser a (Either String Deref)
parseCaret
        case Either String Deref
x of
            Left String
str -> Content -> ParsecT String a Identity Content
forall a. a -> ParsecT String a Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Content -> ParsecT String a Identity Content)
-> Content -> ParsecT String a Identity Content
forall a b. (a -> b) -> a -> b
$ String -> Content
ContentRaw String
str
            Right Deref
deref -> Content -> ParsecT String a Identity Content
forall a. a -> ParsecT String a Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Content -> ParsecT String a Identity Content)
-> Content -> ParsecT String a Identity Content
forall a b. (a -> b) -> a -> b
$ Deref -> Content
ContentEmbed Deref
deref
    contentReg :: ContentRule -> ParsecT s u m Content
contentReg ContentRule
InContent = (String -> Content
ContentRaw (String -> Content) -> (Char -> String) -> Char -> Content
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return) (Char -> Content) -> ParsecT s u m Char -> ParsecT s u m Content
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> ParsecT s u m Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"#@^\r\n"
    contentReg ContentRule
NotInQuotes = (String -> Content
ContentRaw (String -> Content) -> (Char -> String) -> Char -> Content
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return) (Char -> Content) -> ParsecT s u m Char -> ParsecT s u m Content
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> ParsecT s u m Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"@^#. \t\n\r>"
    contentReg ContentRule
NotInQuotesAttr = (String -> Content
ContentRaw (String -> Content) -> (Char -> String) -> Char -> Content
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return) (Char -> Content) -> ParsecT s u m Char -> ParsecT s u m Content
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> ParsecT s u m Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"@^ \t\n\r>"
    contentReg ContentRule
InQuotes = (String -> Content
ContentRaw (String -> Content) -> (Char -> String) -> Char -> Content
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return) (Char -> Content) -> ParsecT s u m Char -> ParsecT s u m Content
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> ParsecT s u m Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
"#@^\"\n\r"
    tagAttribValue :: ContentRule -> ParsecT String u Identity [Content]
tagAttribValue ContentRule
notInQuotes = do
        ContentRule
cr <- (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'"' ParsecT String u Identity Char
-> ParsecT String u Identity ContentRule
-> ParsecT String u Identity ContentRule
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ContentRule -> ParsecT String u Identity ContentRule
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ContentRule
InQuotes) ParsecT String u Identity ContentRule
-> ParsecT String u Identity ContentRule
-> ParsecT String u Identity ContentRule
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ContentRule -> ParsecT String u Identity ContentRule
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ContentRule
notInQuotes
        ContentRule -> ParsecT String u Identity [Content]
forall {u}. ContentRule -> ParsecT String u Identity [Content]
content ContentRule
cr
    tagCond :: ParsecT String u Identity TagPiece
tagCond = do
        Deref
d <- ParsecT String u Identity Char
-> ParsecT String u Identity Char
-> ParsecT String u Identity Deref
-> ParsecT String u Identity Deref
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':') (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':') ParsecT String u Identity Deref
forall a. UserParser a Deref
parseDeref
        Maybe Deref -> ParsecT String u Identity TagPiece
forall {u}. Maybe Deref -> ParsecT String u Identity TagPiece
tagAttrib (Deref -> Maybe Deref
forall a. a -> Maybe a
Just Deref
d)
    tagAttrib :: Maybe Deref -> ParsecT String u Identity TagPiece
tagAttrib Maybe Deref
cond = do
        String
s <- ParsecT String u Identity Char -> ParsecT String u Identity String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT String u Identity Char
 -> ParsecT String u Identity String)
-> ParsecT String u Identity Char
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
" \t=\r\n><"
        [Content]
v <- (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'=' ParsecT String u Identity Char
-> ParsecT String u Identity [Content]
-> ParsecT String u Identity [Content]
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ContentRule -> ParsecT String u Identity [Content]
forall {u}. ContentRule -> ParsecT String u Identity [Content]
tagAttribValue ContentRule
NotInQuotesAttr) ParsecT String u Identity [Content]
-> ParsecT String u Identity [Content]
-> ParsecT String u Identity [Content]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [Content] -> ParsecT String u Identity [Content]
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return []
        TagPiece -> ParsecT String u Identity TagPiece
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (TagPiece -> ParsecT String u Identity TagPiece)
-> TagPiece -> ParsecT String u Identity TagPiece
forall a b. (a -> b) -> a -> b
$ (Maybe Deref, String, [Content]) -> TagPiece
TagAttrib (Maybe Deref
cond, String
s, [Content]
v)

    tagAttrs :: ParsecT String u Identity TagPiece
tagAttrs = do
        Char
_ <- Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'*'
        Deref
d <- ParsecT String u Identity Char
-> ParsecT String u Identity Char
-> ParsecT String u Identity Deref
-> ParsecT String u Identity Deref
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'{') (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}') ParsecT String u Identity Deref
forall a. UserParser a Deref
parseDeref
        TagPiece -> ParsecT String u Identity TagPiece
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (TagPiece -> ParsecT String u Identity TagPiece)
-> TagPiece -> ParsecT String u Identity TagPiece
forall a b. (a -> b) -> a -> b
$ Deref -> TagPiece
TagAttribs Deref
d

    tag' :: [TagPiece] -> (String, [(Maybe Deref, String, [Content])], [Deref])
tag' = (TagPiece
 -> (String, [(Maybe Deref, String, [Content])], [Deref])
 -> (String, [(Maybe Deref, String, [Content])], [Deref]))
-> (String, [(Maybe Deref, String, [Content])], [Deref])
-> [TagPiece]
-> (String, [(Maybe Deref, String, [Content])], [Deref])
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr TagPiece
-> (String, [(Maybe Deref, String, [Content])], [Deref])
-> (String, [(Maybe Deref, String, [Content])], [Deref])
tag'' (String
"div", [], [])
    tag'' :: TagPiece
-> (String, [(Maybe Deref, String, [Content])], [Deref])
-> (String, [(Maybe Deref, String, [Content])], [Deref])
tag'' (TagName String
s) (String
_, [(Maybe Deref, String, [Content])]
y, [Deref]
as) = (String
s, [(Maybe Deref, String, [Content])]
y, [Deref]
as)
    tag'' (TagAttrib (Maybe Deref, String, [Content])
s) (String
x, [(Maybe Deref, String, [Content])]
y, [Deref]
as) = (String
x, (Maybe Deref, String, [Content])
s (Maybe Deref, String, [Content])
-> [(Maybe Deref, String, [Content])]
-> [(Maybe Deref, String, [Content])]
forall a. a -> [a] -> [a]
: [(Maybe Deref, String, [Content])]
y, [Deref]
as)
    tag'' (TagAttribs Deref
s) (String
x, [(Maybe Deref, String, [Content])]
y, [Deref]
as) = (String
x, [(Maybe Deref, String, [Content])]
y, Deref
s Deref -> [Deref] -> [Deref]
forall a. a -> [a] -> [a]
: [Deref]
as)

    ident :: Parser Ident
    ident :: Parser Ident
ident = do
      String
i <- ParsecT String () Identity Char -> GenParser Char () String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'_' ParsecT String () Identity Char
-> ParsecT String () Identity Char
-> ParsecT String () Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\'')
      ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
white
      Ident -> Parser Ident
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Ident
Ident String
i)
     Parser Ident -> String -> Parser Ident
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"identifier"

    parens :: ParsecT String u Identity a -> ParsecT String u Identity a
parens = ParsecT String u Identity ()
-> ParsecT String u Identity ()
-> ParsecT String u Identity a
-> ParsecT String u Identity a
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'(' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white) (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white)

    brackets :: ParsecT String u Identity a -> ParsecT String u Identity a
brackets = ParsecT String u Identity ()
-> ParsecT String u Identity ()
-> ParsecT String u Identity a
-> ParsecT String u Identity a
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'[' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white) (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white)

    braces :: ParsecT String u Identity a -> ParsecT String u Identity a
braces = ParsecT String u Identity ()
-> ParsecT String u Identity ()
-> ParsecT String u Identity a
-> ParsecT String u Identity a
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'{' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white) (Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white)

    comma :: ParsecT String u Identity ()
comma = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white

    atsign :: ParsecT String u Identity ()
atsign = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'@' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white

    equals :: ParsecT String u Identity ()
equals = Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'=' ParsecT String u Identity Char
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white

    white :: ParsecT String u Identity ()
white = ParsecT String u Identity Char -> ParsecT String u Identity ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (ParsecT String u Identity Char -> ParsecT String u Identity ())
-> ParsecT String u Identity Char -> ParsecT String u Identity ()
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
' '

    wildDots :: ParsecT String u Identity ()
wildDots = String -> ParsecT String u Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
".." ParsecT String u Identity String
-> ParsecT String u Identity () -> ParsecT String u Identity ()
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String u Identity ()
forall {u}. ParsecT String u Identity ()
white

    isVariable :: Ident -> Bool
isVariable (Ident (Char
x:String
_)) = Bool -> Bool
not (Char -> Bool
isUpper Char
x)
    isVariable (Ident []) = String -> Bool
forall a. HasCallStack => String -> a
error String
"isVariable: bad identifier"

    isConstructor :: Ident -> Bool
isConstructor (Ident (Char
x:String
_)) = Char -> Bool
isUpper Char
x
    isConstructor (Ident []) = String -> Bool
forall a. HasCallStack => String -> a
error String
"isConstructor: bad identifier"

    identPattern :: Parser Binding
    identPattern :: Parser Binding
identPattern = Bool -> Parser Binding
gcon Bool
True Parser Binding -> Parser Binding -> Parser Binding
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser Binding
apat
      where
      apat :: Parser Binding
apat = [Parser Binding] -> Parser Binding
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
        [ Parser Binding
varpat
        , Bool -> Parser Binding
gcon Bool
False
        , Parser Binding -> Parser Binding
forall {u} {a}.
ParsecT String u Identity a -> ParsecT String u Identity a
parens Parser Binding
tuplepat
        , Parser Binding -> Parser Binding
forall {u} {a}.
ParsecT String u Identity a -> ParsecT String u Identity a
brackets Parser Binding
listpat
        ]

      varpat :: Parser Binding
varpat = do
        Ident
v <- Parser Ident -> Parser Ident
forall tok st a. GenParser tok st a -> GenParser tok st a
try (Parser Ident -> Parser Ident) -> Parser Ident -> Parser Ident
forall a b. (a -> b) -> a -> b
$ do Ident
v <- Parser Ident
ident
                      Bool -> ParsecT String () Identity ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Ident -> Bool
isVariable Ident
v)
                      Ident -> Parser Ident
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Ident
v
        Binding -> Parser Binding -> Parser Binding
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Ident -> Binding
BindVar Ident
v) (Parser Binding -> Parser Binding)
-> Parser Binding -> Parser Binding
forall a b. (a -> b) -> a -> b
$ do
          ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
atsign
          Binding
b <- Parser Binding
apat
          Binding -> Parser Binding
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Binding -> Binding
BindAs Ident
v Binding
b)
       Parser Binding -> String -> Parser Binding
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"variable"

      gcon :: Bool -> Parser Binding
      gcon :: Bool -> Parser Binding
gcon Bool
allowArgs = do
        DataConstr
c <- GenParser Char () DataConstr -> GenParser Char () DataConstr
forall tok st a. GenParser tok st a -> GenParser tok st a
try (GenParser Char () DataConstr -> GenParser Char () DataConstr)
-> GenParser Char () DataConstr -> GenParser Char () DataConstr
forall a b. (a -> b) -> a -> b
$ do DataConstr
c <- GenParser Char () DataConstr
dataConstr
                      DataConstr -> GenParser Char () DataConstr
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return DataConstr
c
        [Parser Binding] -> Parser Binding
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
          [ DataConstr -> Parser Binding
record DataConstr
c
          , ([Binding] -> Binding)
-> ParsecT String () Identity [Binding] -> Parser Binding
forall a b.
(a -> b)
-> ParsecT String () Identity a -> ParsecT String () Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (DataConstr -> [Binding] -> Binding
BindConstr DataConstr
c) (Bool -> ParsecT String () Identity ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard Bool
allowArgs ParsecT String () Identity ()
-> ParsecT String () Identity [Binding]
-> ParsecT String () Identity [Binding]
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser Binding -> ParsecT String () Identity [Binding]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many Parser Binding
apat)
          , Binding -> Parser Binding
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (DataConstr -> [Binding] -> Binding
BindConstr DataConstr
c [])
          ]
       Parser Binding -> String -> Parser Binding
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"constructor"

      dataConstr :: GenParser Char () DataConstr
dataConstr = do
        String
p <- GenParser Char () String
dcPiece
        [String]
ps <- GenParser Char () String -> ParsecT String () Identity [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many GenParser Char () String
dcPieces
        DataConstr -> GenParser Char () DataConstr
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (DataConstr -> GenParser Char () DataConstr)
-> DataConstr -> GenParser Char () DataConstr
forall a b. (a -> b) -> a -> b
$ String -> [String] -> DataConstr
toDataConstr String
p [String]
ps

      dcPiece :: GenParser Char () String
dcPiece = do
        x :: Ident
x@(Ident String
y) <- Parser Ident
ident
        Bool -> ParsecT String () Identity ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT String () Identity ())
-> Bool -> ParsecT String () Identity ()
forall a b. (a -> b) -> a -> b
$ Ident -> Bool
isConstructor Ident
x
        String -> GenParser Char () String
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return String
y

      dcPieces :: GenParser Char () String
dcPieces = do
        Char
_ <- Char -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
        GenParser Char () String
dcPiece

      toDataConstr :: String -> [String] -> DataConstr
toDataConstr String
x [] = Ident -> DataConstr
DCUnqualified (Ident -> DataConstr) -> Ident -> DataConstr
forall a b. (a -> b) -> a -> b
$ String -> Ident
Ident String
x
      toDataConstr String
x (String
y:[String]
ys) =
          ([String] -> [String]) -> String -> [String] -> DataConstr
go (String
xString -> [String] -> [String]
forall a. a -> [a] -> [a]
:) String
y [String]
ys
        where
          go :: ([String] -> [String]) -> String -> [String] -> DataConstr
go [String] -> [String]
front String
next [] = Module -> Ident -> DataConstr
DCQualified ([String] -> Module
Module ([String] -> Module) -> [String] -> Module
forall a b. (a -> b) -> a -> b
$ [String] -> [String]
front []) (String -> Ident
Ident String
next)
          go [String] -> [String]
front String
next (String
rest:[String]
rests) = ([String] -> [String]) -> String -> [String] -> DataConstr
go ([String] -> [String]
front ([String] -> [String])
-> ([String] -> [String]) -> [String] -> [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String
nextString -> [String] -> [String]
forall a. a -> [a] -> [a]
:)) String
rest [String]
rests

      record :: DataConstr -> Parser Binding
record DataConstr
c = Parser Binding -> Parser Binding
forall {u} {a}.
ParsecT String u Identity a -> ParsecT String u Identity a
braces (Parser Binding -> Parser Binding)
-> Parser Binding -> Parser Binding
forall a b. (a -> b) -> a -> b
$ do
        ([(Ident, Binding)]
fields, Bool
wild) <- ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option ([], Bool
False) (ParsecT String () Identity ([(Ident, Binding)], Bool)
 -> ParsecT String () Identity ([(Ident, Binding)], Bool))
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall a b. (a -> b) -> a -> b
$ ParsecT String () Identity ([(Ident, Binding)], Bool)
go
        Binding -> Parser Binding
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (DataConstr -> [(Ident, Binding)] -> Bool -> Binding
BindRecord DataConstr
c [(Ident, Binding)]
fields Bool
wild)
        where
        go :: ParsecT String () Identity ([(Ident, Binding)], Bool)
go = (ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
wildDots ParsecT String () Identity ()
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([], Bool
True))
           ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (do (Ident, Binding)
x         <- ParsecT String () Identity (Ident, Binding)
recordField
                   ([(Ident, Binding)]
xs,Bool
wild) <- ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option ([],Bool
False) (ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
comma ParsecT String () Identity ()
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT String () Identity ([(Ident, Binding)], Bool)
go)
                   ([(Ident, Binding)], Bool)
-> ParsecT String () Identity ([(Ident, Binding)], Bool)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Ident, Binding)
x(Ident, Binding) -> [(Ident, Binding)] -> [(Ident, Binding)]
forall a. a -> [a] -> [a]
:[(Ident, Binding)]
xs,Bool
wild))

      recordField :: ParsecT String () Identity (Ident, Binding)
recordField = do
        Ident
field <- Parser Ident
ident
        Binding
p <- Binding -> Parser Binding -> Parser Binding
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Ident -> Binding
BindVar Ident
field) -- support punning
                    (ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
equals ParsecT String () Identity () -> Parser Binding -> Parser Binding
forall a b.
ParsecT String () Identity a
-> ParsecT String () Identity b -> ParsecT String () Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser Binding
identPattern)
        (Ident, Binding) -> ParsecT String () Identity (Ident, Binding)
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Ident
field,Binding
p)

      tuplepat :: Parser Binding
tuplepat = do
        [Binding]
xs <- Parser Binding
identPattern Parser Binding
-> ParsecT String () Identity ()
-> ParsecT String () Identity [Binding]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
`sepBy` ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
comma
        Binding -> Parser Binding
forall a. a -> ParsecT String () Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Binding -> Parser Binding) -> Binding -> Parser Binding
forall a b. (a -> b) -> a -> b
$ case [Binding]
xs of
          [Binding
x] -> Binding
x
          [Binding]
_   -> [Binding] -> Binding
BindTuple [Binding]
xs

      listpat :: Parser Binding
listpat = [Binding] -> Binding
BindList ([Binding] -> Binding)
-> ParsecT String () Identity [Binding] -> Parser Binding
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Binding
identPattern Parser Binding
-> ParsecT String () Identity ()
-> ParsecT String () Identity [Binding]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
`sepBy` ParsecT String () Identity ()
forall {u}. ParsecT String u Identity ()
comma

    angle :: ParsecT String u Identity Line
angle = do
        Char
_ <- Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'<'
        String
name' <- ParsecT String u Identity Char -> ParsecT String u Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many  (ParsecT String u Identity Char
 -> ParsecT String u Identity String)
-> ParsecT String u Identity Char
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
noneOf String
" \t\r\n>"
        let name :: String
name = if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
name' then String
"div" else String
name'
        [TagPiece]
xs <- ParsecT String u Identity TagPiece
-> ParsecT String u Identity [TagPiece]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String u Identity TagPiece
 -> ParsecT String u Identity [TagPiece])
-> ParsecT String u Identity TagPiece
-> ParsecT String u Identity [TagPiece]
forall a b. (a -> b) -> a -> b
$ ParsecT String u Identity TagPiece
-> ParsecT String u Identity TagPiece
forall tok st a. GenParser tok st a -> GenParser tok st a
try ((ParsecT String u Identity Char -> ParsecT String u Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String u Identity Char
 -> ParsecT String u Identity String)
-> ParsecT String u Identity Char
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
" \t\r\n") ParsecT String u Identity String
-> ParsecT String u Identity TagPiece
-> ParsecT String u Identity TagPiece
forall a b.
ParsecT String u Identity a
-> ParsecT String u Identity b -> ParsecT String u Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
              (ParsecT String u Identity TagPiece
forall {u}. ParsecT String u Identity TagPiece
tagCond ParsecT String u Identity TagPiece
-> ParsecT String u Identity TagPiece
-> ParsecT String u Identity TagPiece
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT String u Identity TagPiece
forall {u}. ParsecT String u Identity TagPiece
tagAttrs ParsecT String u Identity TagPiece
-> ParsecT String u Identity TagPiece
-> ParsecT String u Identity TagPiece
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Maybe Deref -> ParsecT String u Identity TagPiece
forall {u}. Maybe Deref -> ParsecT String u Identity TagPiece
tagAttrib Maybe Deref
forall a. Maybe a
Nothing))
        String
_ <- ParsecT String u Identity Char -> ParsecT String u Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String u Identity Char
 -> ParsecT String u Identity String)
-> ParsecT String u Identity Char
-> ParsecT String u Identity String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
" \t\r\n"
        Char
_ <- Char -> ParsecT String u Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'>'
        [Content]
c <- ContentRule -> ParsecT String u Identity [Content]
forall {u}. ContentRule -> ParsecT String u Identity [Content]
content ContentRule
InContent
        let (String
tn, [(Maybe Deref, String, [Content])]
attr, [Deref]
attrsd) = [TagPiece] -> (String, [(Maybe Deref, String, [Content])], [Deref])
tag' ([TagPiece]
 -> (String, [(Maybe Deref, String, [Content])], [Deref]))
-> [TagPiece]
-> (String, [(Maybe Deref, String, [Content])], [Deref])
forall a b. (a -> b) -> a -> b
$ String -> TagPiece
TagName String
name TagPiece -> [TagPiece] -> [TagPiece]
forall a. a -> [a] -> [a]
: [TagPiece]
xs
        Line -> ParsecT String u Identity Line
forall a. a -> ParsecT String u Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (Line -> ParsecT String u Identity Line)
-> Line -> ParsecT String u Identity Line
forall a b. (a -> b) -> a -> b
$ String
-> [(Maybe Deref, String, [Content])]
-> [Content]
-> [Deref]
-> Line
LineTag String
tn [(Maybe Deref, String, [Content])]
attr [Content]
c [Deref]
attrsd

data TagPiece = TagName String
              | TagAttrib (Maybe Deref, String, [Content])
              | TagAttribs Deref
    deriving Int -> TagPiece -> ShowS
[TagPiece] -> ShowS
TagPiece -> String
(Int -> TagPiece -> ShowS)
-> (TagPiece -> String) -> ([TagPiece] -> ShowS) -> Show TagPiece
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TagPiece -> ShowS
showsPrec :: Int -> TagPiece -> ShowS
$cshow :: TagPiece -> String
show :: TagPiece -> String
$cshowList :: [TagPiece] -> ShowS
showList :: [TagPiece] -> ShowS
Show

data ContentRule = InQuotes | NotInQuotes | NotInQuotesAttr | InContent

data Nest = Nest Line [Nest]

nestLines :: [(Int, Line)] -> [Nest]
nestLines :: [(Int, Line)] -> [Nest]
nestLines [] = []
nestLines ((Int
i, Line
l):[(Int, Line)]
rest) =
    let ([(Int, Line)]
deeper, [(Int, Line)]
rest') = ((Int, Line) -> Bool)
-> [(Int, Line)] -> ([(Int, Line)], [(Int, Line)])
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (\(Int
i', Line
_) -> Int
i' Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
i) [(Int, Line)]
rest
     in Line -> [Nest] -> Nest
Nest Line
l ([(Int, Line)] -> [Nest]
nestLines [(Int, Line)]
deeper) Nest -> [Nest] -> [Nest]
forall a. a -> [a] -> [a]
: [(Int, Line)] -> [Nest]
nestLines [(Int, Line)]
rest'

data Doc = DocForall Deref Binding [Doc]
         | DocWith [(Deref, Binding)] [Doc]
         | DocCond [(Deref, [Doc])] (Maybe [Doc])
         | DocMaybe Deref Binding [Doc] (Maybe [Doc])
         | DocCase Deref [(Binding, [Doc])]
         | DocTag String [(Maybe Deref, String, [Content])] [Deref] [Doc]
         | DocContent Content
         -- FIXME PIs
    deriving (Int -> Doc -> ShowS
[Doc] -> ShowS
Doc -> String
(Int -> Doc -> ShowS)
-> (Doc -> String) -> ([Doc] -> ShowS) -> Show Doc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Doc -> ShowS
showsPrec :: Int -> Doc -> ShowS
$cshow :: Doc -> String
show :: Doc -> String
$cshowList :: [Doc] -> ShowS
showList :: [Doc] -> ShowS
Show, Doc -> Doc -> Bool
(Doc -> Doc -> Bool) -> (Doc -> Doc -> Bool) -> Eq Doc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Doc -> Doc -> Bool
== :: Doc -> Doc -> Bool
$c/= :: Doc -> Doc -> Bool
/= :: Doc -> Doc -> Bool
Eq, ReadPrec [Doc]
ReadPrec Doc
Int -> ReadS Doc
ReadS [Doc]
(Int -> ReadS Doc)
-> ReadS [Doc] -> ReadPrec Doc -> ReadPrec [Doc] -> Read Doc
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Doc
readsPrec :: Int -> ReadS Doc
$creadList :: ReadS [Doc]
readList :: ReadS [Doc]
$creadPrec :: ReadPrec Doc
readPrec :: ReadPrec Doc
$creadListPrec :: ReadPrec [Doc]
readListPrec :: ReadPrec [Doc]
Read, Typeable Doc
Typeable Doc =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Doc -> c Doc)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Doc)
-> (Doc -> Constr)
-> (Doc -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Doc))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Doc))
-> ((forall b. Data b => b -> b) -> Doc -> Doc)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r)
-> (forall u. (forall d. Data d => d -> u) -> Doc -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Doc -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Doc -> m Doc)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Doc -> m Doc)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Doc -> m Doc)
-> Data Doc
Doc -> Constr
Doc -> DataType
(forall b. Data b => b -> b) -> Doc -> Doc
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Doc -> u
forall u. (forall d. Data d => d -> u) -> Doc -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Doc
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Doc -> c Doc
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Doc)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Doc)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Doc -> c Doc
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Doc -> c Doc
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Doc
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Doc
$ctoConstr :: Doc -> Constr
toConstr :: Doc -> Constr
$cdataTypeOf :: Doc -> DataType
dataTypeOf :: Doc -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Doc)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Doc)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Doc)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Doc)
$cgmapT :: (forall b. Data b => b -> b) -> Doc -> Doc
gmapT :: (forall b. Data b => b -> b) -> Doc -> Doc
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doc -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Doc -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Doc -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Doc -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Doc -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Doc -> m Doc
Data, Typeable)

nestToDoc :: [Nest] -> Result [Doc]
nestToDoc :: [Nest] -> Result [Doc]
nestToDoc [] = [Doc] -> Result [Doc]
forall a. a -> Result a
Ok []
nestToDoc (Nest (LineForall Deref
d Binding
i) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    [Doc]
rest' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ Deref -> Binding -> [Doc] -> Doc
DocForall Deref
d Binding
i [Doc]
inside' Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [Doc]
rest'
nestToDoc (Nest (LineWith [(Deref, Binding)]
dis) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    [Doc]
rest' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ [(Deref, Binding)] -> [Doc] -> Doc
DocWith [(Deref, Binding)]
dis [Doc]
inside' Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [Doc]
rest'
nestToDoc (Nest (LineIf Deref
d) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    ([(Deref, [Doc])]
ifs, Maybe [Doc]
el, [Nest]
rest') <- ([(Deref, [Doc])] -> [(Deref, [Doc])])
-> [Nest] -> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
parseConds ((:) (Deref
d, [Doc]
inside')) [Nest]
rest
    [Doc]
rest'' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest'
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ [(Deref, [Doc])] -> Maybe [Doc] -> Doc
DocCond [(Deref, [Doc])]
ifs Maybe [Doc]
el Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [Doc]
rest''
nestToDoc (Nest (LineMaybe Deref
d Binding
i) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    (Maybe [Doc]
nothing, [Nest]
rest') <-
        case [Nest]
rest of
            Nest Line
LineNothing [Nest]
ninside:[Nest]
x -> do
                [Doc]
ninside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
ninside
                (Maybe [Doc], [Nest]) -> Result (Maybe [Doc], [Nest])
forall a. a -> Result a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Doc] -> Maybe [Doc]
forall a. a -> Maybe a
Just [Doc]
ninside', [Nest]
x)
            [Nest]
_ -> (Maybe [Doc], [Nest]) -> Result (Maybe [Doc], [Nest])
forall a. a -> Result a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe [Doc]
forall a. Maybe a
Nothing, [Nest]
rest)
    [Doc]
rest'' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest'
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ Deref -> Binding -> [Doc] -> Maybe [Doc] -> Doc
DocMaybe Deref
d Binding
i [Doc]
inside' Maybe [Doc]
nothing Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [Doc]
rest''
nestToDoc (Nest (LineCase Deref
d) [Nest]
inside:[Nest]
rest) = do
    let getOf :: Nest -> Result (Binding, [Doc])
getOf (Nest (LineOf Binding
x) [Nest]
insideC) = do
            [Doc]
insideC' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
insideC
            (Binding, [Doc]) -> Result (Binding, [Doc])
forall a. a -> Result a
Ok (Binding
x, [Doc]
insideC')
        getOf Nest
_ = String -> Result (Binding, [Doc])
forall v. String -> Result v
Error String
"Inside a $case there may only be $of.  Use '$of _' for a wildcard."
    [(Binding, [Doc])]
cases <- (Nest -> Result (Binding, [Doc]))
-> [Nest] -> Result [(Binding, [Doc])]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Nest -> Result (Binding, [Doc])
getOf [Nest]
inside
    [Doc]
rest' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ Deref -> [(Binding, [Doc])] -> Doc
DocCase Deref
d [(Binding, [Doc])]
cases Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [Doc]
rest'
nestToDoc (Nest (LineTag String
tn [(Maybe Deref, String, [Content])]
attrs [Content]
content [Deref]
attrsD) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    [Doc]
rest' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ (String
-> [(Maybe Deref, String, [Content])] -> [Deref] -> [Doc] -> Doc
DocTag String
tn [(Maybe Deref, String, [Content])]
attrs [Deref]
attrsD ([Doc] -> Doc) -> [Doc] -> Doc
forall a b. (a -> b) -> a -> b
$ (Content -> Doc) -> [Content] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map Content -> Doc
DocContent [Content]
content [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++ [Doc]
inside') Doc -> [Doc] -> [Doc]
forall a. a -> [a] -> [a]
: [Doc]
rest'
nestToDoc (Nest (LineContent [Content]
content) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    [Doc]
rest' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
rest
    [Doc] -> Result [Doc]
forall a. a -> Result a
Ok ([Doc] -> Result [Doc]) -> [Doc] -> Result [Doc]
forall a b. (a -> b) -> a -> b
$ (Content -> Doc) -> [Content] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map Content -> Doc
DocContent [Content]
content [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++ [Doc]
inside' [Doc] -> [Doc] -> [Doc]
forall a. [a] -> [a] -> [a]
++ [Doc]
rest'
nestToDoc (Nest (LineElseIf Deref
_) [Nest]
_:[Nest]
_) = String -> Result [Doc]
forall v. String -> Result v
Error String
"Unexpected elseif"
nestToDoc (Nest Line
LineElse [Nest]
_:[Nest]
_) = String -> Result [Doc]
forall v. String -> Result v
Error String
"Unexpected else"
nestToDoc (Nest Line
LineNothing [Nest]
_:[Nest]
_) = String -> Result [Doc]
forall v. String -> Result v
Error String
"Unexpected nothing"
nestToDoc (Nest (LineOf Binding
_) [Nest]
_:[Nest]
_) = String -> Result [Doc]
forall v. String -> Result v
Error String
"Unexpected 'of' (did you forget a $case?)"

parseDoc :: String -> Result [Doc]
parseDoc :: String -> Result [Doc]
parseDoc String
s = do
    [(Int, Line)]
ls <- String -> Result [(Int, Line)]
parseLines String
s
    let notEmpty :: (a, Line) -> Bool
notEmpty (a
_, LineContent []) = Bool
False
        notEmpty (a, Line)
_ = Bool
True
    let ns :: [Nest]
ns = [(Int, Line)] -> [Nest]
nestLines ([(Int, Line)] -> [Nest]) -> [(Int, Line)] -> [Nest]
forall a b. (a -> b) -> a -> b
$ ((Int, Line) -> Bool) -> [(Int, Line)] -> [(Int, Line)]
forall a. (a -> Bool) -> [a] -> [a]
filter (Int, Line) -> Bool
forall {a}. (a, Line) -> Bool
notEmpty [(Int, Line)]
ls
    [Doc]
ds <- [Nest] -> Result [Doc]
nestToDoc [Nest]
ns
    [Doc] -> Result [Doc]
forall a. a -> Result a
forall (m :: * -> *) a. Monad m => a -> m a
return [Doc]
ds

parseConds :: ([(Deref, [Doc])] -> [(Deref, [Doc])])
           -> [Nest]
           -> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
parseConds :: ([(Deref, [Doc])] -> [(Deref, [Doc])])
-> [Nest] -> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
parseConds [(Deref, [Doc])] -> [(Deref, [Doc])]
front (Nest Line
LineElse [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    ([(Deref, [Doc])], Maybe [Doc], [Nest])
-> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
forall a. a -> Result a
Ok (([(Deref, [Doc])], Maybe [Doc], [Nest])
 -> Result ([(Deref, [Doc])], Maybe [Doc], [Nest]))
-> ([(Deref, [Doc])], Maybe [Doc], [Nest])
-> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
forall a b. (a -> b) -> a -> b
$ ([(Deref, [Doc])] -> [(Deref, [Doc])]
front [], [Doc] -> Maybe [Doc]
forall a. a -> Maybe a
Just [Doc]
inside', [Nest]
rest)
parseConds [(Deref, [Doc])] -> [(Deref, [Doc])]
front (Nest (LineElseIf Deref
d) [Nest]
inside:[Nest]
rest) = do
    [Doc]
inside' <- [Nest] -> Result [Doc]
nestToDoc [Nest]
inside
    ([(Deref, [Doc])] -> [(Deref, [Doc])])
-> [Nest] -> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
parseConds ([(Deref, [Doc])] -> [(Deref, [Doc])]
front ([(Deref, [Doc])] -> [(Deref, [Doc])])
-> ([(Deref, [Doc])] -> [(Deref, [Doc])])
-> [(Deref, [Doc])]
-> [(Deref, [Doc])]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:) (Deref
d, [Doc]
inside')) [Nest]
rest
parseConds [(Deref, [Doc])] -> [(Deref, [Doc])]
front [Nest]
rest = ([(Deref, [Doc])], Maybe [Doc], [Nest])
-> Result ([(Deref, [Doc])], Maybe [Doc], [Nest])
forall a. a -> Result a
Ok ([(Deref, [Doc])] -> [(Deref, [Doc])]
front [], Maybe [Doc]
forall a. Maybe a
Nothing, [Nest]
rest)

data Binding = BindVar Ident
             | BindAs Ident Binding
             | BindConstr DataConstr [Binding]
             | BindTuple [Binding]
             | BindList [Binding]
             | BindRecord DataConstr [(Ident, Binding)] Bool
    deriving (Binding -> Binding -> Bool
(Binding -> Binding -> Bool)
-> (Binding -> Binding -> Bool) -> Eq Binding
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Binding -> Binding -> Bool
== :: Binding -> Binding -> Bool
$c/= :: Binding -> Binding -> Bool
/= :: Binding -> Binding -> Bool
Eq, Int -> Binding -> ShowS
[Binding] -> ShowS
Binding -> String
(Int -> Binding -> ShowS)
-> (Binding -> String) -> ([Binding] -> ShowS) -> Show Binding
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Binding -> ShowS
showsPrec :: Int -> Binding -> ShowS
$cshow :: Binding -> String
show :: Binding -> String
$cshowList :: [Binding] -> ShowS
showList :: [Binding] -> ShowS
Show, ReadPrec [Binding]
ReadPrec Binding
Int -> ReadS Binding
ReadS [Binding]
(Int -> ReadS Binding)
-> ReadS [Binding]
-> ReadPrec Binding
-> ReadPrec [Binding]
-> Read Binding
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Binding
readsPrec :: Int -> ReadS Binding
$creadList :: ReadS [Binding]
readList :: ReadS [Binding]
$creadPrec :: ReadPrec Binding
readPrec :: ReadPrec Binding
$creadListPrec :: ReadPrec [Binding]
readListPrec :: ReadPrec [Binding]
Read, Typeable Binding
Typeable Binding =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Binding -> c Binding)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Binding)
-> (Binding -> Constr)
-> (Binding -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Binding))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binding))
-> ((forall b. Data b => b -> b) -> Binding -> Binding)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Binding -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Binding -> r)
-> (forall u. (forall d. Data d => d -> u) -> Binding -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Binding -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Binding -> m Binding)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Binding -> m Binding)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Binding -> m Binding)
-> Data Binding
Binding -> Constr
Binding -> DataType
(forall b. Data b => b -> b) -> Binding -> Binding
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Binding -> u
forall u. (forall d. Data d => d -> u) -> Binding -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Binding -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Binding -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Binding
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Binding -> c Binding
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Binding)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binding)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Binding -> c Binding
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Binding -> c Binding
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Binding
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Binding
$ctoConstr :: Binding -> Constr
toConstr :: Binding -> Constr
$cdataTypeOf :: Binding -> DataType
dataTypeOf :: Binding -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Binding)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Binding)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binding)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Binding)
$cgmapT :: (forall b. Data b => b -> b) -> Binding -> Binding
gmapT :: (forall b. Data b => b -> b) -> Binding -> Binding
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Binding -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Binding -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Binding -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Binding -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Binding -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Binding -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Binding -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Binding -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Binding -> m Binding
Data, Typeable)

data DataConstr = DCQualified Module Ident
                | DCUnqualified Ident
    deriving (DataConstr -> DataConstr -> Bool
(DataConstr -> DataConstr -> Bool)
-> (DataConstr -> DataConstr -> Bool) -> Eq DataConstr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataConstr -> DataConstr -> Bool
== :: DataConstr -> DataConstr -> Bool
$c/= :: DataConstr -> DataConstr -> Bool
/= :: DataConstr -> DataConstr -> Bool
Eq, Int -> DataConstr -> ShowS
[DataConstr] -> ShowS
DataConstr -> String
(Int -> DataConstr -> ShowS)
-> (DataConstr -> String)
-> ([DataConstr] -> ShowS)
-> Show DataConstr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DataConstr -> ShowS
showsPrec :: Int -> DataConstr -> ShowS
$cshow :: DataConstr -> String
show :: DataConstr -> String
$cshowList :: [DataConstr] -> ShowS
showList :: [DataConstr] -> ShowS
Show, ReadPrec [DataConstr]
ReadPrec DataConstr
Int -> ReadS DataConstr
ReadS [DataConstr]
(Int -> ReadS DataConstr)
-> ReadS [DataConstr]
-> ReadPrec DataConstr
-> ReadPrec [DataConstr]
-> Read DataConstr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DataConstr
readsPrec :: Int -> ReadS DataConstr
$creadList :: ReadS [DataConstr]
readList :: ReadS [DataConstr]
$creadPrec :: ReadPrec DataConstr
readPrec :: ReadPrec DataConstr
$creadListPrec :: ReadPrec [DataConstr]
readListPrec :: ReadPrec [DataConstr]
Read, Typeable DataConstr
Typeable DataConstr =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> DataConstr -> c DataConstr)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c DataConstr)
-> (DataConstr -> Constr)
-> (DataConstr -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c DataConstr))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c DataConstr))
-> ((forall b. Data b => b -> b) -> DataConstr -> DataConstr)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> DataConstr -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> DataConstr -> r)
-> (forall u. (forall d. Data d => d -> u) -> DataConstr -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> DataConstr -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> DataConstr -> m DataConstr)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataConstr -> m DataConstr)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> DataConstr -> m DataConstr)
-> Data DataConstr
DataConstr -> Constr
DataConstr -> DataType
(forall b. Data b => b -> b) -> DataConstr -> DataConstr
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> DataConstr -> u
forall u. (forall d. Data d => d -> u) -> DataConstr -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConstr -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataConstr -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConstr
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConstr -> c DataConstr
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConstr)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConstr)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConstr -> c DataConstr
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DataConstr -> c DataConstr
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConstr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c DataConstr
$ctoConstr :: DataConstr -> Constr
toConstr :: DataConstr -> Constr
$cdataTypeOf :: DataConstr -> DataType
dataTypeOf :: DataConstr -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConstr)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c DataConstr)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConstr)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DataConstr)
$cgmapT :: (forall b. Data b => b -> b) -> DataConstr -> DataConstr
gmapT :: (forall b. Data b => b -> b) -> DataConstr -> DataConstr
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConstr -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> DataConstr -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataConstr -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> DataConstr -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> DataConstr -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> DataConstr -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConstr -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DataConstr -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DataConstr -> m DataConstr
Data, Typeable)

newtype Module = Module [String]
    deriving (Module -> Module -> Bool
(Module -> Module -> Bool)
-> (Module -> Module -> Bool) -> Eq Module
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Module -> Module -> Bool
== :: Module -> Module -> Bool
$c/= :: Module -> Module -> Bool
/= :: Module -> Module -> Bool
Eq, Int -> Module -> ShowS
[Module] -> ShowS
Module -> String
(Int -> Module -> ShowS)
-> (Module -> String) -> ([Module] -> ShowS) -> Show Module
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Module -> ShowS
showsPrec :: Int -> Module -> ShowS
$cshow :: Module -> String
show :: Module -> String
$cshowList :: [Module] -> ShowS
showList :: [Module] -> ShowS
Show, ReadPrec [Module]
ReadPrec Module
Int -> ReadS Module
ReadS [Module]
(Int -> ReadS Module)
-> ReadS [Module]
-> ReadPrec Module
-> ReadPrec [Module]
-> Read Module
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Module
readsPrec :: Int -> ReadS Module
$creadList :: ReadS [Module]
readList :: ReadS [Module]
$creadPrec :: ReadPrec Module
readPrec :: ReadPrec Module
$creadListPrec :: ReadPrec [Module]
readListPrec :: ReadPrec [Module]
Read, Typeable Module
Typeable Module =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Module -> c Module)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Module)
-> (Module -> Constr)
-> (Module -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Module))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module))
-> ((forall b. Data b => b -> b) -> Module -> Module)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Module -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Module -> r)
-> (forall u. (forall d. Data d => d -> u) -> Module -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Module -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Module -> m Module)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Module -> m Module)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Module -> m Module)
-> Data Module
Module -> Constr
Module -> DataType
(forall b. Data b => b -> b) -> Module -> Module
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Module -> u
forall u. (forall d. Data d => d -> u) -> Module -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Module -> m Module
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Module
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Module -> c Module
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Module)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Module -> c Module
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Module -> c Module
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Module
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Module
$ctoConstr :: Module -> Constr
toConstr :: Module -> Constr
$cdataTypeOf :: Module -> DataType
dataTypeOf :: Module -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Module)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Module)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module)
$cgmapT :: (forall b. Data b => b -> b) -> Module -> Module
gmapT :: (forall b. Data b => b -> b) -> Module -> Module
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Module -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Module -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Module -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Module -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Module -> m Module
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Module -> m Module
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
Data, Typeable)

spaceTabs :: Parser String
spaceTabs :: GenParser Char () String
spaceTabs = ParsecT String () Identity Char -> GenParser Char () String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String () Identity Char -> GenParser Char () String)
-> ParsecT String () Identity Char -> GenParser Char () String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
" \t"