{-# LANGUAGE StrictData                 #-}
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeSynonymInstances       #-}

-- | Basic types for Skylighting.
module Skylighting.Types (
              -- * Syntax descriptions
                ContextName
              , KeywordAttr(..)
              , WordSet(..)
              , makeWordSet
              , inWordSet
              , ListItem(..)
              , Matcher(..)
              , Rule(..)
              , Context(..)
              , ContextSwitch(..)
              , Syntax(..)
              , SyntaxMap
              -- * Tokens
              , Token
              , TokenType(..)
              , SourceLine
              , LineNo(..)
              -- * Styles
              , TokenStyle(..)
              , defStyle
              , Color(..)
              , ToColor(..)
              , FromColor(..)
              , Style(..)
              , ANSIColorLevel(..)
              -- * Format options
              , FormatOptions(..)
              , defaultFormatOpts
              ) where

import Control.Monad (mplus)
import Data.Aeson
import Data.Aeson.Types (toJSONKeyText)
import Data.Binary (Binary)
import Data.Bits
import Data.CaseInsensitive (FoldCase (..))
import Data.Colour.SRGB (Colour, sRGB24, toSRGB24)
import qualified Data.Colour.SRGB as Colour
import Data.Data (Data)
import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Typeable (Typeable)
import Data.Word
import GHC.Generics (Generic)
import Safe (readMay)
import Skylighting.Regex
import Text.Printf

-- | Full name of a context: the first member of the pair is the full
-- syntax name, the second the context name within that syntax.
type ContextName = (Text, Text)

-- | Attributes controlling how keywords are interpreted.
data KeywordAttr =
  KeywordAttr  { KeywordAttr -> Bool
keywordCaseSensitive :: !Bool
               , KeywordAttr -> Set Char
keywordDelims        :: !(Set.Set Char)
               }
  deriving (Int -> KeywordAttr -> ShowS
[KeywordAttr] -> ShowS
KeywordAttr -> String
(Int -> KeywordAttr -> ShowS)
-> (KeywordAttr -> String)
-> ([KeywordAttr] -> ShowS)
-> Show KeywordAttr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> KeywordAttr -> ShowS
showsPrec :: Int -> KeywordAttr -> ShowS
$cshow :: KeywordAttr -> String
show :: KeywordAttr -> String
$cshowList :: [KeywordAttr] -> ShowS
showList :: [KeywordAttr] -> ShowS
Show, ReadPrec [KeywordAttr]
ReadPrec KeywordAttr
Int -> ReadS KeywordAttr
ReadS [KeywordAttr]
(Int -> ReadS KeywordAttr)
-> ReadS [KeywordAttr]
-> ReadPrec KeywordAttr
-> ReadPrec [KeywordAttr]
-> Read KeywordAttr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS KeywordAttr
readsPrec :: Int -> ReadS KeywordAttr
$creadList :: ReadS [KeywordAttr]
readList :: ReadS [KeywordAttr]
$creadPrec :: ReadPrec KeywordAttr
readPrec :: ReadPrec KeywordAttr
$creadListPrec :: ReadPrec [KeywordAttr]
readListPrec :: ReadPrec [KeywordAttr]
Read, KeywordAttr -> KeywordAttr -> Bool
(KeywordAttr -> KeywordAttr -> Bool)
-> (KeywordAttr -> KeywordAttr -> Bool) -> Eq KeywordAttr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: KeywordAttr -> KeywordAttr -> Bool
== :: KeywordAttr -> KeywordAttr -> Bool
$c/= :: KeywordAttr -> KeywordAttr -> Bool
/= :: KeywordAttr -> KeywordAttr -> Bool
Eq, Eq KeywordAttr
Eq KeywordAttr =>
(KeywordAttr -> KeywordAttr -> Ordering)
-> (KeywordAttr -> KeywordAttr -> Bool)
-> (KeywordAttr -> KeywordAttr -> Bool)
-> (KeywordAttr -> KeywordAttr -> Bool)
-> (KeywordAttr -> KeywordAttr -> Bool)
-> (KeywordAttr -> KeywordAttr -> KeywordAttr)
-> (KeywordAttr -> KeywordAttr -> KeywordAttr)
-> Ord KeywordAttr
KeywordAttr -> KeywordAttr -> Bool
KeywordAttr -> KeywordAttr -> Ordering
KeywordAttr -> KeywordAttr -> KeywordAttr
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: KeywordAttr -> KeywordAttr -> Ordering
compare :: KeywordAttr -> KeywordAttr -> Ordering
$c< :: KeywordAttr -> KeywordAttr -> Bool
< :: KeywordAttr -> KeywordAttr -> Bool
$c<= :: KeywordAttr -> KeywordAttr -> Bool
<= :: KeywordAttr -> KeywordAttr -> Bool
$c> :: KeywordAttr -> KeywordAttr -> Bool
> :: KeywordAttr -> KeywordAttr -> Bool
$c>= :: KeywordAttr -> KeywordAttr -> Bool
>= :: KeywordAttr -> KeywordAttr -> Bool
$cmax :: KeywordAttr -> KeywordAttr -> KeywordAttr
max :: KeywordAttr -> KeywordAttr -> KeywordAttr
$cmin :: KeywordAttr -> KeywordAttr -> KeywordAttr
min :: KeywordAttr -> KeywordAttr -> KeywordAttr
Ord, Typeable KeywordAttr
Typeable KeywordAttr =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> KeywordAttr -> c KeywordAttr)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c KeywordAttr)
-> (KeywordAttr -> Constr)
-> (KeywordAttr -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c KeywordAttr))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c KeywordAttr))
-> ((forall b. Data b => b -> b) -> KeywordAttr -> KeywordAttr)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r)
-> (forall u. (forall d. Data d => d -> u) -> KeywordAttr -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> KeywordAttr -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr)
-> Data KeywordAttr
KeywordAttr -> Constr
KeywordAttr -> DataType
(forall b. Data b => b -> b) -> KeywordAttr -> KeywordAttr
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) -> KeywordAttr -> u
forall u. (forall d. Data d => d -> u) -> KeywordAttr -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KeywordAttr
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KeywordAttr -> c KeywordAttr
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KeywordAttr)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KeywordAttr)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KeywordAttr -> c KeywordAttr
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KeywordAttr -> c KeywordAttr
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KeywordAttr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c KeywordAttr
$ctoConstr :: KeywordAttr -> Constr
toConstr :: KeywordAttr -> Constr
$cdataTypeOf :: KeywordAttr -> DataType
dataTypeOf :: KeywordAttr -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KeywordAttr)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KeywordAttr)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KeywordAttr)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c KeywordAttr)
$cgmapT :: (forall b. Data b => b -> b) -> KeywordAttr -> KeywordAttr
gmapT :: (forall b. Data b => b -> b) -> KeywordAttr -> KeywordAttr
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> KeywordAttr -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KeywordAttr -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> KeywordAttr -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KeywordAttr -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KeywordAttr -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> KeywordAttr -> m KeywordAttr
Data, Typeable, (forall x. KeywordAttr -> Rep KeywordAttr x)
-> (forall x. Rep KeywordAttr x -> KeywordAttr)
-> Generic KeywordAttr
forall x. Rep KeywordAttr x -> KeywordAttr
forall x. KeywordAttr -> Rep KeywordAttr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. KeywordAttr -> Rep KeywordAttr x
from :: forall x. KeywordAttr -> Rep KeywordAttr x
$cto :: forall x. Rep KeywordAttr x -> KeywordAttr
to :: forall x. Rep KeywordAttr x -> KeywordAttr
Generic)

instance Binary KeywordAttr

-- | A set of "words," possibly case insensitive.
data WordSet a = CaseSensitiveWords !(Set.Set a)
               | CaseInsensitiveWords !(Set.Set a)
     deriving (Int -> WordSet a -> ShowS
[WordSet a] -> ShowS
WordSet a -> String
(Int -> WordSet a -> ShowS)
-> (WordSet a -> String)
-> ([WordSet a] -> ShowS)
-> Show (WordSet a)
forall a. Show a => Int -> WordSet a -> ShowS
forall a. Show a => [WordSet a] -> ShowS
forall a. Show a => WordSet a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> WordSet a -> ShowS
showsPrec :: Int -> WordSet a -> ShowS
$cshow :: forall a. Show a => WordSet a -> String
show :: WordSet a -> String
$cshowList :: forall a. Show a => [WordSet a] -> ShowS
showList :: [WordSet a] -> ShowS
Show, ReadPrec [WordSet a]
ReadPrec (WordSet a)
Int -> ReadS (WordSet a)
ReadS [WordSet a]
(Int -> ReadS (WordSet a))
-> ReadS [WordSet a]
-> ReadPrec (WordSet a)
-> ReadPrec [WordSet a]
-> Read (WordSet a)
forall a. (Read a, Ord a) => ReadPrec [WordSet a]
forall a. (Read a, Ord a) => ReadPrec (WordSet a)
forall a. (Read a, Ord a) => Int -> ReadS (WordSet a)
forall a. (Read a, Ord a) => ReadS [WordSet a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. (Read a, Ord a) => Int -> ReadS (WordSet a)
readsPrec :: Int -> ReadS (WordSet a)
$creadList :: forall a. (Read a, Ord a) => ReadS [WordSet a]
readList :: ReadS [WordSet a]
$creadPrec :: forall a. (Read a, Ord a) => ReadPrec (WordSet a)
readPrec :: ReadPrec (WordSet a)
$creadListPrec :: forall a. (Read a, Ord a) => ReadPrec [WordSet a]
readListPrec :: ReadPrec [WordSet a]
Read, WordSet a -> WordSet a -> Bool
(WordSet a -> WordSet a -> Bool)
-> (WordSet a -> WordSet a -> Bool) -> Eq (WordSet a)
forall a. Eq a => WordSet a -> WordSet a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => WordSet a -> WordSet a -> Bool
== :: WordSet a -> WordSet a -> Bool
$c/= :: forall a. Eq a => WordSet a -> WordSet a -> Bool
/= :: WordSet a -> WordSet a -> Bool
Eq, Eq (WordSet a)
Eq (WordSet a) =>
(WordSet a -> WordSet a -> Ordering)
-> (WordSet a -> WordSet a -> Bool)
-> (WordSet a -> WordSet a -> Bool)
-> (WordSet a -> WordSet a -> Bool)
-> (WordSet a -> WordSet a -> Bool)
-> (WordSet a -> WordSet a -> WordSet a)
-> (WordSet a -> WordSet a -> WordSet a)
-> Ord (WordSet a)
WordSet a -> WordSet a -> Bool
WordSet a -> WordSet a -> Ordering
WordSet a -> WordSet a -> WordSet a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (WordSet a)
forall a. Ord a => WordSet a -> WordSet a -> Bool
forall a. Ord a => WordSet a -> WordSet a -> Ordering
forall a. Ord a => WordSet a -> WordSet a -> WordSet a
$ccompare :: forall a. Ord a => WordSet a -> WordSet a -> Ordering
compare :: WordSet a -> WordSet a -> Ordering
$c< :: forall a. Ord a => WordSet a -> WordSet a -> Bool
< :: WordSet a -> WordSet a -> Bool
$c<= :: forall a. Ord a => WordSet a -> WordSet a -> Bool
<= :: WordSet a -> WordSet a -> Bool
$c> :: forall a. Ord a => WordSet a -> WordSet a -> Bool
> :: WordSet a -> WordSet a -> Bool
$c>= :: forall a. Ord a => WordSet a -> WordSet a -> Bool
>= :: WordSet a -> WordSet a -> Bool
$cmax :: forall a. Ord a => WordSet a -> WordSet a -> WordSet a
max :: WordSet a -> WordSet a -> WordSet a
$cmin :: forall a. Ord a => WordSet a -> WordSet a -> WordSet a
min :: WordSet a -> WordSet a -> WordSet a
Ord, Typeable (WordSet a)
Typeable (WordSet a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> WordSet a -> c (WordSet a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (WordSet a))
-> (WordSet a -> Constr)
-> (WordSet a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (WordSet a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (WordSet a)))
-> ((forall b. Data b => b -> b) -> WordSet a -> WordSet a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> WordSet a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> WordSet a -> r)
-> (forall u. (forall d. Data d => d -> u) -> WordSet a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> WordSet a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a))
-> Data (WordSet a)
WordSet a -> Constr
WordSet a -> DataType
(forall b. Data b => b -> b) -> WordSet a -> WordSet a
forall a. (Data a, Ord a) => Typeable (WordSet a)
forall a. (Data a, Ord a) => WordSet a -> Constr
forall a. (Data a, Ord a) => WordSet a -> DataType
forall a.
(Data a, Ord a) =>
(forall b. Data b => b -> b) -> WordSet a -> WordSet a
forall a u.
(Data a, Ord a) =>
Int -> (forall d. Data d => d -> u) -> WordSet a -> u
forall a u.
(Data a, Ord a) =>
(forall d. Data d => d -> u) -> WordSet a -> [u]
forall a r r'.
(Data a, Ord a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
forall a r r'.
(Data a, Ord a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
forall a (m :: * -> *).
(Data a, Ord a, Monad m) =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
forall a (m :: * -> *).
(Data a, Ord a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
forall a (c :: * -> *).
(Data a, Ord a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WordSet a)
forall a (c :: * -> *).
(Data a, Ord a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WordSet a -> c (WordSet a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Ord a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WordSet a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Ord a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WordSet a))
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) -> WordSet a -> u
forall u. (forall d. Data d => d -> u) -> WordSet a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WordSet a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WordSet a -> c (WordSet a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (WordSet a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WordSet a))
$cgfoldl :: forall a (c :: * -> *).
(Data a, Ord a) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WordSet a -> c (WordSet a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WordSet a -> c (WordSet a)
$cgunfold :: forall a (c :: * -> *).
(Data a, Ord a) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WordSet a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (WordSet a)
$ctoConstr :: forall a. (Data a, Ord a) => WordSet a -> Constr
toConstr :: WordSet a -> Constr
$cdataTypeOf :: forall a. (Data a, Ord a) => WordSet a -> DataType
dataTypeOf :: WordSet a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Ord a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (WordSet a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (WordSet a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Ord a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WordSet a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (WordSet a))
$cgmapT :: forall a.
(Data a, Ord a) =>
(forall b. Data b => b -> b) -> WordSet a -> WordSet a
gmapT :: (forall b. Data b => b -> b) -> WordSet a -> WordSet a
$cgmapQl :: forall a r r'.
(Data a, Ord a) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
$cgmapQr :: forall a r r'.
(Data a, Ord a) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WordSet a -> r
$cgmapQ :: forall a u.
(Data a, Ord a) =>
(forall d. Data d => d -> u) -> WordSet a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> WordSet a -> [u]
$cgmapQi :: forall a u.
(Data a, Ord a) =>
Int -> (forall d. Data d => d -> u) -> WordSet a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> WordSet a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Ord a, Monad m) =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, Ord a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, Ord a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WordSet a -> m (WordSet a)
Data, Typeable, (forall x. WordSet a -> Rep (WordSet a) x)
-> (forall x. Rep (WordSet a) x -> WordSet a)
-> Generic (WordSet a)
forall x. Rep (WordSet a) x -> WordSet a
forall x. WordSet a -> Rep (WordSet a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (WordSet a) x -> WordSet a
forall a x. WordSet a -> Rep (WordSet a) x
$cfrom :: forall a x. WordSet a -> Rep (WordSet a) x
from :: forall x. WordSet a -> Rep (WordSet a) x
$cto :: forall a x. Rep (WordSet a) x -> WordSet a
to :: forall x. Rep (WordSet a) x -> WordSet a
Generic)

instance Binary a => Binary (WordSet a)

-- | A set of words to match (either case-sensitive or case-insensitive).
makeWordSet :: (FoldCase a, Ord a) => Bool -> [a] -> WordSet a
makeWordSet :: forall a. (FoldCase a, Ord a) => Bool -> [a] -> WordSet a
makeWordSet Bool
True [a]
ws  = Set a -> WordSet a
forall a. Set a -> WordSet a
CaseSensitiveWords ([a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList [a]
ws)
makeWordSet Bool
False [a]
ws = Set a -> WordSet a
forall a. Set a -> WordSet a
CaseInsensitiveWords ([a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList ([a] -> Set a) -> [a] -> Set a
forall a b. (a -> b) -> a -> b
$ (a -> a) -> [a] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map a -> a
forall s. FoldCase s => s -> s
foldCase [a]
ws)

-- | Test for membership in a 'WordSet'.
inWordSet :: (FoldCase a, Ord a) => a -> WordSet a -> Bool
inWordSet :: forall a. (FoldCase a, Ord a) => a -> WordSet a -> Bool
inWordSet a
w (CaseInsensitiveWords Set a
ws) = a -> a
forall s. FoldCase s => s -> s
foldCase a
w a -> Set a -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set a
ws
inWordSet a
w (CaseSensitiveWords Set a
ws)   = a
w a -> Set a -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set a
ws

-- | Matchers correspond to the element types in a context.
data Matcher =
    DetectChar !Char
  | Detect2Chars !Char !Char
  | AnyChar !(Set.Set Char)
  | RangeDetect !Char !Char
  | StringDetect !Text
  | WordDetect !Text
  | RegExpr !RE
  | Keyword !KeywordAttr (Either Text (WordSet Text))
      -- Either Left list name (unresolved) or Right wordset (resolved)
  | Int
  | Float
  | HlCOct
  | HlCHex
  | HlCStringChar
  | HlCChar
  | LineContinue
  | IncludeRules !ContextName
  | DetectSpaces
  | DetectIdentifier
  deriving (Int -> Matcher -> ShowS
[Matcher] -> ShowS
Matcher -> String
(Int -> Matcher -> ShowS)
-> (Matcher -> String) -> ([Matcher] -> ShowS) -> Show Matcher
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Matcher -> ShowS
showsPrec :: Int -> Matcher -> ShowS
$cshow :: Matcher -> String
show :: Matcher -> String
$cshowList :: [Matcher] -> ShowS
showList :: [Matcher] -> ShowS
Show, ReadPrec [Matcher]
ReadPrec Matcher
Int -> ReadS Matcher
ReadS [Matcher]
(Int -> ReadS Matcher)
-> ReadS [Matcher]
-> ReadPrec Matcher
-> ReadPrec [Matcher]
-> Read Matcher
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Matcher
readsPrec :: Int -> ReadS Matcher
$creadList :: ReadS [Matcher]
readList :: ReadS [Matcher]
$creadPrec :: ReadPrec Matcher
readPrec :: ReadPrec Matcher
$creadListPrec :: ReadPrec [Matcher]
readListPrec :: ReadPrec [Matcher]
Read, Matcher -> Matcher -> Bool
(Matcher -> Matcher -> Bool)
-> (Matcher -> Matcher -> Bool) -> Eq Matcher
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Matcher -> Matcher -> Bool
== :: Matcher -> Matcher -> Bool
$c/= :: Matcher -> Matcher -> Bool
/= :: Matcher -> Matcher -> Bool
Eq, Eq Matcher
Eq Matcher =>
(Matcher -> Matcher -> Ordering)
-> (Matcher -> Matcher -> Bool)
-> (Matcher -> Matcher -> Bool)
-> (Matcher -> Matcher -> Bool)
-> (Matcher -> Matcher -> Bool)
-> (Matcher -> Matcher -> Matcher)
-> (Matcher -> Matcher -> Matcher)
-> Ord Matcher
Matcher -> Matcher -> Bool
Matcher -> Matcher -> Ordering
Matcher -> Matcher -> Matcher
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Matcher -> Matcher -> Ordering
compare :: Matcher -> Matcher -> Ordering
$c< :: Matcher -> Matcher -> Bool
< :: Matcher -> Matcher -> Bool
$c<= :: Matcher -> Matcher -> Bool
<= :: Matcher -> Matcher -> Bool
$c> :: Matcher -> Matcher -> Bool
> :: Matcher -> Matcher -> Bool
$c>= :: Matcher -> Matcher -> Bool
>= :: Matcher -> Matcher -> Bool
$cmax :: Matcher -> Matcher -> Matcher
max :: Matcher -> Matcher -> Matcher
$cmin :: Matcher -> Matcher -> Matcher
min :: Matcher -> Matcher -> Matcher
Ord, Typeable Matcher
Typeable Matcher =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Matcher -> c Matcher)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Matcher)
-> (Matcher -> Constr)
-> (Matcher -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Matcher))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Matcher))
-> ((forall b. Data b => b -> b) -> Matcher -> Matcher)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Matcher -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Matcher -> r)
-> (forall u. (forall d. Data d => d -> u) -> Matcher -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Matcher -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Matcher -> m Matcher)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Matcher -> m Matcher)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Matcher -> m Matcher)
-> Data Matcher
Matcher -> Constr
Matcher -> DataType
(forall b. Data b => b -> b) -> Matcher -> Matcher
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) -> Matcher -> u
forall u. (forall d. Data d => d -> u) -> Matcher -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Matcher -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Matcher -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Matcher
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Matcher -> c Matcher
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Matcher)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Matcher)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Matcher -> c Matcher
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Matcher -> c Matcher
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Matcher
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Matcher
$ctoConstr :: Matcher -> Constr
toConstr :: Matcher -> Constr
$cdataTypeOf :: Matcher -> DataType
dataTypeOf :: Matcher -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Matcher)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Matcher)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Matcher)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Matcher)
$cgmapT :: (forall b. Data b => b -> b) -> Matcher -> Matcher
gmapT :: (forall b. Data b => b -> b) -> Matcher -> Matcher
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Matcher -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Matcher -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Matcher -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Matcher -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Matcher -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Matcher -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Matcher -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Matcher -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Matcher -> m Matcher
Data, Typeable, (forall x. Matcher -> Rep Matcher x)
-> (forall x. Rep Matcher x -> Matcher) -> Generic Matcher
forall x. Rep Matcher x -> Matcher
forall x. Matcher -> Rep Matcher x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Matcher -> Rep Matcher x
from :: forall x. Matcher -> Rep Matcher x
$cto :: forall x. Rep Matcher x -> Matcher
to :: forall x. Rep Matcher x -> Matcher
Generic)

instance Binary Matcher

-- | A context switch, either pops or pushes a context.
data ContextSwitch =
  Pop | Push !ContextName
  deriving (Int -> ContextSwitch -> ShowS
[ContextSwitch] -> ShowS
ContextSwitch -> String
(Int -> ContextSwitch -> ShowS)
-> (ContextSwitch -> String)
-> ([ContextSwitch] -> ShowS)
-> Show ContextSwitch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContextSwitch -> ShowS
showsPrec :: Int -> ContextSwitch -> ShowS
$cshow :: ContextSwitch -> String
show :: ContextSwitch -> String
$cshowList :: [ContextSwitch] -> ShowS
showList :: [ContextSwitch] -> ShowS
Show, ReadPrec [ContextSwitch]
ReadPrec ContextSwitch
Int -> ReadS ContextSwitch
ReadS [ContextSwitch]
(Int -> ReadS ContextSwitch)
-> ReadS [ContextSwitch]
-> ReadPrec ContextSwitch
-> ReadPrec [ContextSwitch]
-> Read ContextSwitch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ContextSwitch
readsPrec :: Int -> ReadS ContextSwitch
$creadList :: ReadS [ContextSwitch]
readList :: ReadS [ContextSwitch]
$creadPrec :: ReadPrec ContextSwitch
readPrec :: ReadPrec ContextSwitch
$creadListPrec :: ReadPrec [ContextSwitch]
readListPrec :: ReadPrec [ContextSwitch]
Read, ContextSwitch -> ContextSwitch -> Bool
(ContextSwitch -> ContextSwitch -> Bool)
-> (ContextSwitch -> ContextSwitch -> Bool) -> Eq ContextSwitch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContextSwitch -> ContextSwitch -> Bool
== :: ContextSwitch -> ContextSwitch -> Bool
$c/= :: ContextSwitch -> ContextSwitch -> Bool
/= :: ContextSwitch -> ContextSwitch -> Bool
Eq, Eq ContextSwitch
Eq ContextSwitch =>
(ContextSwitch -> ContextSwitch -> Ordering)
-> (ContextSwitch -> ContextSwitch -> Bool)
-> (ContextSwitch -> ContextSwitch -> Bool)
-> (ContextSwitch -> ContextSwitch -> Bool)
-> (ContextSwitch -> ContextSwitch -> Bool)
-> (ContextSwitch -> ContextSwitch -> ContextSwitch)
-> (ContextSwitch -> ContextSwitch -> ContextSwitch)
-> Ord ContextSwitch
ContextSwitch -> ContextSwitch -> Bool
ContextSwitch -> ContextSwitch -> Ordering
ContextSwitch -> ContextSwitch -> ContextSwitch
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ContextSwitch -> ContextSwitch -> Ordering
compare :: ContextSwitch -> ContextSwitch -> Ordering
$c< :: ContextSwitch -> ContextSwitch -> Bool
< :: ContextSwitch -> ContextSwitch -> Bool
$c<= :: ContextSwitch -> ContextSwitch -> Bool
<= :: ContextSwitch -> ContextSwitch -> Bool
$c> :: ContextSwitch -> ContextSwitch -> Bool
> :: ContextSwitch -> ContextSwitch -> Bool
$c>= :: ContextSwitch -> ContextSwitch -> Bool
>= :: ContextSwitch -> ContextSwitch -> Bool
$cmax :: ContextSwitch -> ContextSwitch -> ContextSwitch
max :: ContextSwitch -> ContextSwitch -> ContextSwitch
$cmin :: ContextSwitch -> ContextSwitch -> ContextSwitch
min :: ContextSwitch -> ContextSwitch -> ContextSwitch
Ord, Typeable ContextSwitch
Typeable ContextSwitch =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ContextSwitch -> c ContextSwitch)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ContextSwitch)
-> (ContextSwitch -> Constr)
-> (ContextSwitch -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ContextSwitch))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ContextSwitch))
-> ((forall b. Data b => b -> b) -> ContextSwitch -> ContextSwitch)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r)
-> (forall u. (forall d. Data d => d -> u) -> ContextSwitch -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ContextSwitch -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch)
-> Data ContextSwitch
ContextSwitch -> Constr
ContextSwitch -> DataType
(forall b. Data b => b -> b) -> ContextSwitch -> ContextSwitch
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) -> ContextSwitch -> u
forall u. (forall d. Data d => d -> u) -> ContextSwitch -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ContextSwitch
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ContextSwitch -> c ContextSwitch
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ContextSwitch)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ContextSwitch)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ContextSwitch -> c ContextSwitch
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ContextSwitch -> c ContextSwitch
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ContextSwitch
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ContextSwitch
$ctoConstr :: ContextSwitch -> Constr
toConstr :: ContextSwitch -> Constr
$cdataTypeOf :: ContextSwitch -> DataType
dataTypeOf :: ContextSwitch -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ContextSwitch)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ContextSwitch)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ContextSwitch)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ContextSwitch)
$cgmapT :: (forall b. Data b => b -> b) -> ContextSwitch -> ContextSwitch
gmapT :: (forall b. Data b => b -> b) -> ContextSwitch -> ContextSwitch
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ContextSwitch -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ContextSwitch -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ContextSwitch -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ContextSwitch -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ContextSwitch -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ContextSwitch -> m ContextSwitch
Data, Typeable, (forall x. ContextSwitch -> Rep ContextSwitch x)
-> (forall x. Rep ContextSwitch x -> ContextSwitch)
-> Generic ContextSwitch
forall x. Rep ContextSwitch x -> ContextSwitch
forall x. ContextSwitch -> Rep ContextSwitch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ContextSwitch -> Rep ContextSwitch x
from :: forall x. ContextSwitch -> Rep ContextSwitch x
$cto :: forall x. Rep ContextSwitch x -> ContextSwitch
to :: forall x. Rep ContextSwitch x -> ContextSwitch
Generic)

instance Binary ContextSwitch

-- | A rule corresponds to one of the elements of a Kate syntax
-- highlighting "context."
data Rule = Rule{
    Rule -> Matcher
rMatcher          :: !Matcher
  , Rule -> TokenType
rAttribute        :: !TokenType
  , Rule -> Bool
rIncludeAttribute :: !Bool
  , Rule -> Set Char
rWeakDeliminators :: Set.Set Char
  , Rule -> Bool
rDynamic          :: !Bool
  , Rule -> Bool
rCaseSensitive    :: !Bool
  , Rule -> [Rule]
rChildren         :: ![Rule]
  , Rule -> Bool
rLookahead        :: !Bool
  , Rule -> Bool
rFirstNonspace    :: !Bool
  , Rule -> Maybe Int
rColumn           :: !(Maybe Int)
  , Rule -> [ContextSwitch]
rContextSwitch    :: ![ContextSwitch]
  } deriving (Int -> Rule -> ShowS
[Rule] -> ShowS
Rule -> String
(Int -> Rule -> ShowS)
-> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Rule -> ShowS
showsPrec :: Int -> Rule -> ShowS
$cshow :: Rule -> String
show :: Rule -> String
$cshowList :: [Rule] -> ShowS
showList :: [Rule] -> ShowS
Show, ReadPrec [Rule]
ReadPrec Rule
Int -> ReadS Rule
ReadS [Rule]
(Int -> ReadS Rule)
-> ReadS [Rule] -> ReadPrec Rule -> ReadPrec [Rule] -> Read Rule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Rule
readsPrec :: Int -> ReadS Rule
$creadList :: ReadS [Rule]
readList :: ReadS [Rule]
$creadPrec :: ReadPrec Rule
readPrec :: ReadPrec Rule
$creadListPrec :: ReadPrec [Rule]
readListPrec :: ReadPrec [Rule]
Read, Rule -> Rule -> Bool
(Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
/= :: Rule -> Rule -> Bool
Eq, Eq Rule
Eq Rule =>
(Rule -> Rule -> Ordering)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Bool)
-> (Rule -> Rule -> Rule)
-> (Rule -> Rule -> Rule)
-> Ord Rule
Rule -> Rule -> Bool
Rule -> Rule -> Ordering
Rule -> Rule -> Rule
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Rule -> Rule -> Ordering
compare :: Rule -> Rule -> Ordering
$c< :: Rule -> Rule -> Bool
< :: Rule -> Rule -> Bool
$c<= :: Rule -> Rule -> Bool
<= :: Rule -> Rule -> Bool
$c> :: Rule -> Rule -> Bool
> :: Rule -> Rule -> Bool
$c>= :: Rule -> Rule -> Bool
>= :: Rule -> Rule -> Bool
$cmax :: Rule -> Rule -> Rule
max :: Rule -> Rule -> Rule
$cmin :: Rule -> Rule -> Rule
min :: Rule -> Rule -> Rule
Ord, Typeable Rule
Typeable Rule =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Rule -> c Rule)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Rule)
-> (Rule -> Constr)
-> (Rule -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Rule))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rule))
-> ((forall b. Data b => b -> b) -> Rule -> Rule)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r)
-> (forall u. (forall d. Data d => d -> u) -> Rule -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Rule -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Rule -> m Rule)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Rule -> m Rule)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Rule -> m Rule)
-> Data Rule
Rule -> Constr
Rule -> DataType
(forall b. Data b => b -> b) -> Rule -> Rule
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) -> Rule -> u
forall u. (forall d. Data d => d -> u) -> Rule -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Rule
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Rule -> c Rule
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Rule)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rule)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Rule -> c Rule
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Rule -> c Rule
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Rule
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Rule
$ctoConstr :: Rule -> Constr
toConstr :: Rule -> Constr
$cdataTypeOf :: Rule -> DataType
dataTypeOf :: Rule -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Rule)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Rule)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rule)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rule)
$cgmapT :: (forall b. Data b => b -> b) -> Rule -> Rule
gmapT :: (forall b. Data b => b -> b) -> Rule -> Rule
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rule -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Rule -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Rule -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Rule -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Rule -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Rule -> m Rule
Data, Typeable, (forall x. Rule -> Rep Rule x)
-> (forall x. Rep Rule x -> Rule) -> Generic Rule
forall x. Rep Rule x -> Rule
forall x. Rule -> Rep Rule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Rule -> Rep Rule x
from :: forall x. Rule -> Rep Rule x
$cto :: forall x. Rep Rule x -> Rule
to :: forall x. Rep Rule x -> Rule
Generic)

instance Binary Rule

-- | A list item is either just a textual value or an included list.
-- IncludeList (x,y) includes list y from syntax with full name x.
data ListItem = Item !Text | IncludeList !(Text, Text)
  deriving (Int -> ListItem -> ShowS
[ListItem] -> ShowS
ListItem -> String
(Int -> ListItem -> ShowS)
-> (ListItem -> String) -> ([ListItem] -> ShowS) -> Show ListItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListItem -> ShowS
showsPrec :: Int -> ListItem -> ShowS
$cshow :: ListItem -> String
show :: ListItem -> String
$cshowList :: [ListItem] -> ShowS
showList :: [ListItem] -> ShowS
Show, ListItem -> ListItem -> Bool
(ListItem -> ListItem -> Bool)
-> (ListItem -> ListItem -> Bool) -> Eq ListItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListItem -> ListItem -> Bool
== :: ListItem -> ListItem -> Bool
$c/= :: ListItem -> ListItem -> Bool
/= :: ListItem -> ListItem -> Bool
Eq, Eq ListItem
Eq ListItem =>
(ListItem -> ListItem -> Ordering)
-> (ListItem -> ListItem -> Bool)
-> (ListItem -> ListItem -> Bool)
-> (ListItem -> ListItem -> Bool)
-> (ListItem -> ListItem -> Bool)
-> (ListItem -> ListItem -> ListItem)
-> (ListItem -> ListItem -> ListItem)
-> Ord ListItem
ListItem -> ListItem -> Bool
ListItem -> ListItem -> Ordering
ListItem -> ListItem -> ListItem
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ListItem -> ListItem -> Ordering
compare :: ListItem -> ListItem -> Ordering
$c< :: ListItem -> ListItem -> Bool
< :: ListItem -> ListItem -> Bool
$c<= :: ListItem -> ListItem -> Bool
<= :: ListItem -> ListItem -> Bool
$c> :: ListItem -> ListItem -> Bool
> :: ListItem -> ListItem -> Bool
$c>= :: ListItem -> ListItem -> Bool
>= :: ListItem -> ListItem -> Bool
$cmax :: ListItem -> ListItem -> ListItem
max :: ListItem -> ListItem -> ListItem
$cmin :: ListItem -> ListItem -> ListItem
min :: ListItem -> ListItem -> ListItem
Ord, ReadPrec [ListItem]
ReadPrec ListItem
Int -> ReadS ListItem
ReadS [ListItem]
(Int -> ReadS ListItem)
-> ReadS [ListItem]
-> ReadPrec ListItem
-> ReadPrec [ListItem]
-> Read ListItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ListItem
readsPrec :: Int -> ReadS ListItem
$creadList :: ReadS [ListItem]
readList :: ReadS [ListItem]
$creadPrec :: ReadPrec ListItem
readPrec :: ReadPrec ListItem
$creadListPrec :: ReadPrec [ListItem]
readListPrec :: ReadPrec [ListItem]
Read, Typeable ListItem
Typeable ListItem =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ListItem -> c ListItem)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ListItem)
-> (ListItem -> Constr)
-> (ListItem -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ListItem))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ListItem))
-> ((forall b. Data b => b -> b) -> ListItem -> ListItem)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ListItem -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ListItem -> r)
-> (forall u. (forall d. Data d => d -> u) -> ListItem -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ListItem -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ListItem -> m ListItem)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ListItem -> m ListItem)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ListItem -> m ListItem)
-> Data ListItem
ListItem -> Constr
ListItem -> DataType
(forall b. Data b => b -> b) -> ListItem -> ListItem
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) -> ListItem -> u
forall u. (forall d. Data d => d -> u) -> ListItem -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListItem -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListItem -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ListItem
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListItem -> c ListItem
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ListItem)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ListItem)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListItem -> c ListItem
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListItem -> c ListItem
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ListItem
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ListItem
$ctoConstr :: ListItem -> Constr
toConstr :: ListItem -> Constr
$cdataTypeOf :: ListItem -> DataType
dataTypeOf :: ListItem -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ListItem)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ListItem)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ListItem)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ListItem)
$cgmapT :: (forall b. Data b => b -> b) -> ListItem -> ListItem
gmapT :: (forall b. Data b => b -> b) -> ListItem -> ListItem
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListItem -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListItem -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListItem -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListItem -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ListItem -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ListItem -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ListItem -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ListItem -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListItem -> m ListItem
Data, Typeable, (forall x. ListItem -> Rep ListItem x)
-> (forall x. Rep ListItem x -> ListItem) -> Generic ListItem
forall x. Rep ListItem x -> ListItem
forall x. ListItem -> Rep ListItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ListItem -> Rep ListItem x
from :: forall x. ListItem -> Rep ListItem x
$cto :: forall x. Rep ListItem x -> ListItem
to :: forall x. Rep ListItem x -> ListItem
Generic)

instance Binary ListItem

-- | A syntax corresponds to a complete Kate syntax description.
-- The 'sShortname' field is derived from the filename.
data Syntax = Syntax{
    Syntax -> Text
sName            :: !Text
  , Syntax -> String
sFilename        :: !String
  , Syntax -> Text
sShortname       :: !Text
  , Syntax -> Map Text [ListItem]
sLists           :: !(Map.Map Text [ListItem])
  , Syntax -> Map Text Context
sContexts        :: !(Map.Map Text Context)
  , Syntax -> Text
sAuthor          :: !Text
  , Syntax -> Text
sVersion         :: !Text
  , Syntax -> Text
sLicense         :: !Text
  , Syntax -> [String]
sExtensions      :: ![String]
  , Syntax -> Text
sStartingContext :: !Text
  } deriving (Int -> Syntax -> ShowS
[Syntax] -> ShowS
Syntax -> String
(Int -> Syntax -> ShowS)
-> (Syntax -> String) -> ([Syntax] -> ShowS) -> Show Syntax
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Syntax -> ShowS
showsPrec :: Int -> Syntax -> ShowS
$cshow :: Syntax -> String
show :: Syntax -> String
$cshowList :: [Syntax] -> ShowS
showList :: [Syntax] -> ShowS
Show, ReadPrec [Syntax]
ReadPrec Syntax
Int -> ReadS Syntax
ReadS [Syntax]
(Int -> ReadS Syntax)
-> ReadS [Syntax]
-> ReadPrec Syntax
-> ReadPrec [Syntax]
-> Read Syntax
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Syntax
readsPrec :: Int -> ReadS Syntax
$creadList :: ReadS [Syntax]
readList :: ReadS [Syntax]
$creadPrec :: ReadPrec Syntax
readPrec :: ReadPrec Syntax
$creadListPrec :: ReadPrec [Syntax]
readListPrec :: ReadPrec [Syntax]
Read, Syntax -> Syntax -> Bool
(Syntax -> Syntax -> Bool)
-> (Syntax -> Syntax -> Bool) -> Eq Syntax
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Syntax -> Syntax -> Bool
== :: Syntax -> Syntax -> Bool
$c/= :: Syntax -> Syntax -> Bool
/= :: Syntax -> Syntax -> Bool
Eq, Eq Syntax
Eq Syntax =>
(Syntax -> Syntax -> Ordering)
-> (Syntax -> Syntax -> Bool)
-> (Syntax -> Syntax -> Bool)
-> (Syntax -> Syntax -> Bool)
-> (Syntax -> Syntax -> Bool)
-> (Syntax -> Syntax -> Syntax)
-> (Syntax -> Syntax -> Syntax)
-> Ord Syntax
Syntax -> Syntax -> Bool
Syntax -> Syntax -> Ordering
Syntax -> Syntax -> Syntax
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Syntax -> Syntax -> Ordering
compare :: Syntax -> Syntax -> Ordering
$c< :: Syntax -> Syntax -> Bool
< :: Syntax -> Syntax -> Bool
$c<= :: Syntax -> Syntax -> Bool
<= :: Syntax -> Syntax -> Bool
$c> :: Syntax -> Syntax -> Bool
> :: Syntax -> Syntax -> Bool
$c>= :: Syntax -> Syntax -> Bool
>= :: Syntax -> Syntax -> Bool
$cmax :: Syntax -> Syntax -> Syntax
max :: Syntax -> Syntax -> Syntax
$cmin :: Syntax -> Syntax -> Syntax
min :: Syntax -> Syntax -> Syntax
Ord, Typeable Syntax
Typeable Syntax =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Syntax -> c Syntax)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Syntax)
-> (Syntax -> Constr)
-> (Syntax -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Syntax))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Syntax))
-> ((forall b. Data b => b -> b) -> Syntax -> Syntax)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Syntax -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Syntax -> r)
-> (forall u. (forall d. Data d => d -> u) -> Syntax -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Syntax -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Syntax -> m Syntax)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Syntax -> m Syntax)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Syntax -> m Syntax)
-> Data Syntax
Syntax -> Constr
Syntax -> DataType
(forall b. Data b => b -> b) -> Syntax -> Syntax
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) -> Syntax -> u
forall u. (forall d. Data d => d -> u) -> Syntax -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Syntax -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Syntax -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Syntax
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Syntax -> c Syntax
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Syntax)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Syntax)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Syntax -> c Syntax
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Syntax -> c Syntax
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Syntax
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Syntax
$ctoConstr :: Syntax -> Constr
toConstr :: Syntax -> Constr
$cdataTypeOf :: Syntax -> DataType
dataTypeOf :: Syntax -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Syntax)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Syntax)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Syntax)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Syntax)
$cgmapT :: (forall b. Data b => b -> b) -> Syntax -> Syntax
gmapT :: (forall b. Data b => b -> b) -> Syntax -> Syntax
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Syntax -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Syntax -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Syntax -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Syntax -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Syntax -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Syntax -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Syntax -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Syntax -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Syntax -> m Syntax
Data, Typeable, (forall x. Syntax -> Rep Syntax x)
-> (forall x. Rep Syntax x -> Syntax) -> Generic Syntax
forall x. Rep Syntax x -> Syntax
forall x. Syntax -> Rep Syntax x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Syntax -> Rep Syntax x
from :: forall x. Syntax -> Rep Syntax x
$cto :: forall x. Rep Syntax x -> Syntax
to :: forall x. Rep Syntax x -> Syntax
Generic)

instance Binary Syntax

-- | A map of syntaxes, keyed by full name.
type SyntaxMap = Map.Map Text Syntax

-- | A Context corresponds to a context element in a Kate
-- syntax description.
data Context = Context{
    Context -> Text
cName               :: !Text
  , Context -> Text
cSyntax             :: !Text
  , Context -> [Rule]
cRules              :: ![Rule]
  , Context -> TokenType
cAttribute          :: !TokenType
  , Context -> [ContextSwitch]
cLineEmptyContext   :: ![ContextSwitch]
  , Context -> [ContextSwitch]
cLineEndContext     :: ![ContextSwitch]
  , Context -> [ContextSwitch]
cLineBeginContext   :: ![ContextSwitch]
  , Context -> Bool
cFallthrough        :: !Bool
  , Context -> [ContextSwitch]
cFallthroughContext :: ![ContextSwitch]
  , Context -> Bool
cDynamic            :: !Bool
} deriving (Int -> Context -> ShowS
[Context] -> ShowS
Context -> String
(Int -> Context -> ShowS)
-> (Context -> String) -> ([Context] -> ShowS) -> Show Context
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Context -> ShowS
showsPrec :: Int -> Context -> ShowS
$cshow :: Context -> String
show :: Context -> String
$cshowList :: [Context] -> ShowS
showList :: [Context] -> ShowS
Show, ReadPrec [Context]
ReadPrec Context
Int -> ReadS Context
ReadS [Context]
(Int -> ReadS Context)
-> ReadS [Context]
-> ReadPrec Context
-> ReadPrec [Context]
-> Read Context
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Context
readsPrec :: Int -> ReadS Context
$creadList :: ReadS [Context]
readList :: ReadS [Context]
$creadPrec :: ReadPrec Context
readPrec :: ReadPrec Context
$creadListPrec :: ReadPrec [Context]
readListPrec :: ReadPrec [Context]
Read, Context -> Context -> Bool
(Context -> Context -> Bool)
-> (Context -> Context -> Bool) -> Eq Context
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Context -> Context -> Bool
== :: Context -> Context -> Bool
$c/= :: Context -> Context -> Bool
/= :: Context -> Context -> Bool
Eq, Eq Context
Eq Context =>
(Context -> Context -> Ordering)
-> (Context -> Context -> Bool)
-> (Context -> Context -> Bool)
-> (Context -> Context -> Bool)
-> (Context -> Context -> Bool)
-> (Context -> Context -> Context)
-> (Context -> Context -> Context)
-> Ord Context
Context -> Context -> Bool
Context -> Context -> Ordering
Context -> Context -> Context
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Context -> Context -> Ordering
compare :: Context -> Context -> Ordering
$c< :: Context -> Context -> Bool
< :: Context -> Context -> Bool
$c<= :: Context -> Context -> Bool
<= :: Context -> Context -> Bool
$c> :: Context -> Context -> Bool
> :: Context -> Context -> Bool
$c>= :: Context -> Context -> Bool
>= :: Context -> Context -> Bool
$cmax :: Context -> Context -> Context
max :: Context -> Context -> Context
$cmin :: Context -> Context -> Context
min :: Context -> Context -> Context
Ord, Typeable Context
Typeable Context =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Context -> c Context)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Context)
-> (Context -> Constr)
-> (Context -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Context))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Context))
-> ((forall b. Data b => b -> b) -> Context -> Context)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Context -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Context -> r)
-> (forall u. (forall d. Data d => d -> u) -> Context -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Context -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Context -> m Context)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Context -> m Context)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Context -> m Context)
-> Data Context
Context -> Constr
Context -> DataType
(forall b. Data b => b -> b) -> Context -> Context
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) -> Context -> u
forall u. (forall d. Data d => d -> u) -> Context -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Context -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Context -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Context -> m Context
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Context -> m Context
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Context
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Context -> c Context
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Context)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Context)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Context -> c Context
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Context -> c Context
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Context
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Context
$ctoConstr :: Context -> Constr
toConstr :: Context -> Constr
$cdataTypeOf :: Context -> DataType
dataTypeOf :: Context -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Context)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Context)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Context)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Context)
$cgmapT :: (forall b. Data b => b -> b) -> Context -> Context
gmapT :: (forall b. Data b => b -> b) -> Context -> Context
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Context -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Context -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Context -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Context -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Context -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Context -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Context -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Context -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Context -> m Context
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Context -> m Context
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Context -> m Context
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Context -> m Context
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Context -> m Context
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Context -> m Context
Data, Typeable, (forall x. Context -> Rep Context x)
-> (forall x. Rep Context x -> Context) -> Generic Context
forall x. Rep Context x -> Context
forall x. Context -> Rep Context x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Context -> Rep Context x
from :: forall x. Context -> Rep Context x
$cto :: forall x. Rep Context x -> Context
to :: forall x. Rep Context x -> Context
Generic)

instance Binary Context

-- | A pair consisting of a list of attributes and some text.
type Token = (TokenType, Text)

-- | 'KeywordTok' corresponds to @dsKeyword@ in Kate syntax
-- descriptions, and so on.
data TokenType = KeywordTok
               | DataTypeTok
               | DecValTok
               | BaseNTok
               | FloatTok
               | ConstantTok
               | CharTok
               | SpecialCharTok
               | StringTok
               | VerbatimStringTok
               | SpecialStringTok
               | ImportTok
               | CommentTok
               | DocumentationTok
               | AnnotationTok
               | CommentVarTok
               | OtherTok
               | FunctionTok
               | VariableTok
               | ControlFlowTok
               | OperatorTok
               | BuiltInTok
               | ExtensionTok
               | PreprocessorTok
               | AttributeTok
               | RegionMarkerTok
               | InformationTok
               | WarningTok
               | AlertTok
               | ErrorTok
               | NormalTok
               deriving (ReadPrec [TokenType]
ReadPrec TokenType
Int -> ReadS TokenType
ReadS [TokenType]
(Int -> ReadS TokenType)
-> ReadS [TokenType]
-> ReadPrec TokenType
-> ReadPrec [TokenType]
-> Read TokenType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TokenType
readsPrec :: Int -> ReadS TokenType
$creadList :: ReadS [TokenType]
readList :: ReadS [TokenType]
$creadPrec :: ReadPrec TokenType
readPrec :: ReadPrec TokenType
$creadListPrec :: ReadPrec [TokenType]
readListPrec :: ReadPrec [TokenType]
Read, Int -> TokenType -> ShowS
[TokenType] -> ShowS
TokenType -> String
(Int -> TokenType -> ShowS)
-> (TokenType -> String)
-> ([TokenType] -> ShowS)
-> Show TokenType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TokenType -> ShowS
showsPrec :: Int -> TokenType -> ShowS
$cshow :: TokenType -> String
show :: TokenType -> String
$cshowList :: [TokenType] -> ShowS
showList :: [TokenType] -> ShowS
Show, TokenType -> TokenType -> Bool
(TokenType -> TokenType -> Bool)
-> (TokenType -> TokenType -> Bool) -> Eq TokenType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TokenType -> TokenType -> Bool
== :: TokenType -> TokenType -> Bool
$c/= :: TokenType -> TokenType -> Bool
/= :: TokenType -> TokenType -> Bool
Eq, Eq TokenType
Eq TokenType =>
(TokenType -> TokenType -> Ordering)
-> (TokenType -> TokenType -> Bool)
-> (TokenType -> TokenType -> Bool)
-> (TokenType -> TokenType -> Bool)
-> (TokenType -> TokenType -> Bool)
-> (TokenType -> TokenType -> TokenType)
-> (TokenType -> TokenType -> TokenType)
-> Ord TokenType
TokenType -> TokenType -> Bool
TokenType -> TokenType -> Ordering
TokenType -> TokenType -> TokenType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TokenType -> TokenType -> Ordering
compare :: TokenType -> TokenType -> Ordering
$c< :: TokenType -> TokenType -> Bool
< :: TokenType -> TokenType -> Bool
$c<= :: TokenType -> TokenType -> Bool
<= :: TokenType -> TokenType -> Bool
$c> :: TokenType -> TokenType -> Bool
> :: TokenType -> TokenType -> Bool
$c>= :: TokenType -> TokenType -> Bool
>= :: TokenType -> TokenType -> Bool
$cmax :: TokenType -> TokenType -> TokenType
max :: TokenType -> TokenType -> TokenType
$cmin :: TokenType -> TokenType -> TokenType
min :: TokenType -> TokenType -> TokenType
Ord, Int -> TokenType
TokenType -> Int
TokenType -> [TokenType]
TokenType -> TokenType
TokenType -> TokenType -> [TokenType]
TokenType -> TokenType -> TokenType -> [TokenType]
(TokenType -> TokenType)
-> (TokenType -> TokenType)
-> (Int -> TokenType)
-> (TokenType -> Int)
-> (TokenType -> [TokenType])
-> (TokenType -> TokenType -> [TokenType])
-> (TokenType -> TokenType -> [TokenType])
-> (TokenType -> TokenType -> TokenType -> [TokenType])
-> Enum TokenType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: TokenType -> TokenType
succ :: TokenType -> TokenType
$cpred :: TokenType -> TokenType
pred :: TokenType -> TokenType
$ctoEnum :: Int -> TokenType
toEnum :: Int -> TokenType
$cfromEnum :: TokenType -> Int
fromEnum :: TokenType -> Int
$cenumFrom :: TokenType -> [TokenType]
enumFrom :: TokenType -> [TokenType]
$cenumFromThen :: TokenType -> TokenType -> [TokenType]
enumFromThen :: TokenType -> TokenType -> [TokenType]
$cenumFromTo :: TokenType -> TokenType -> [TokenType]
enumFromTo :: TokenType -> TokenType -> [TokenType]
$cenumFromThenTo :: TokenType -> TokenType -> TokenType -> [TokenType]
enumFromThenTo :: TokenType -> TokenType -> TokenType -> [TokenType]
Enum, TokenType
TokenType -> TokenType -> Bounded TokenType
forall a. a -> a -> Bounded a
$cminBound :: TokenType
minBound :: TokenType
$cmaxBound :: TokenType
maxBound :: TokenType
Bounded, Typeable TokenType
Typeable TokenType =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> TokenType -> c TokenType)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TokenType)
-> (TokenType -> Constr)
-> (TokenType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TokenType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenType))
-> ((forall b. Data b => b -> b) -> TokenType -> TokenType)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TokenType -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TokenType -> r)
-> (forall u. (forall d. Data d => d -> u) -> TokenType -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TokenType -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TokenType -> m TokenType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TokenType -> m TokenType)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TokenType -> m TokenType)
-> Data TokenType
TokenType -> Constr
TokenType -> DataType
(forall b. Data b => b -> b) -> TokenType -> TokenType
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) -> TokenType -> u
forall u. (forall d. Data d => d -> u) -> TokenType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenType -> c TokenType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenType)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenType -> c TokenType
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenType -> c TokenType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenType
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenType
$ctoConstr :: TokenType -> Constr
toConstr :: TokenType -> Constr
$cdataTypeOf :: TokenType -> DataType
dataTypeOf :: TokenType -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenType)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenType)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenType)
$cgmapT :: (forall b. Data b => b -> b) -> TokenType -> TokenType
gmapT :: (forall b. Data b => b -> b) -> TokenType -> TokenType
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenType -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenType -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenType -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TokenType -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TokenType -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TokenType -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TokenType -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenType -> m TokenType
Data, Typeable, (forall x. TokenType -> Rep TokenType x)
-> (forall x. Rep TokenType x -> TokenType) -> Generic TokenType
forall x. Rep TokenType x -> TokenType
forall x. TokenType -> Rep TokenType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TokenType -> Rep TokenType x
from :: forall x. TokenType -> Rep TokenType x
$cto :: forall x. Rep TokenType x -> TokenType
to :: forall x. Rep TokenType x -> TokenType
Generic)

instance Binary TokenType

instance ToJSON TokenType where
  toEncoding :: TokenType -> Encoding
toEncoding = Maybe Text -> Encoding
forall a. ToJSON a => a -> Encoding
toEncoding (Maybe Text -> Encoding)
-> (TokenType -> Maybe Text) -> TokenType -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> Maybe Text
Text.stripSuffix Text
"Tok" (Text -> Maybe Text)
-> (TokenType -> Text) -> TokenType -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack (String -> Text) -> (TokenType -> String) -> TokenType -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TokenType -> String
forall a. Show a => a -> String
show

instance ToJSONKey TokenType where
  toJSONKey :: ToJSONKeyFunction TokenType
toJSONKey = (TokenType -> Text) -> ToJSONKeyFunction TokenType
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText
    (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"Unknown" (Maybe Text -> Text)
-> (TokenType -> Maybe Text) -> TokenType -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> Maybe Text
Text.stripSuffix Text
"Tok" (Text -> Maybe Text)
-> (TokenType -> Text) -> TokenType -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
Text.pack (String -> Text) -> (TokenType -> String) -> TokenType -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TokenType -> String
forall a. Show a => a -> String
show)

instance FromJSON TokenType where
  parseJSON :: Value -> Parser TokenType
parseJSON (String Text
t) =
     case String -> Maybe TokenType
forall a. Read a => String -> Maybe a
readMay (Text -> String
Text.unpack Text
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"Tok") of
          Just TokenType
tt -> TokenType -> Parser TokenType
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TokenType
tt
          Maybe TokenType
Nothing -> String -> Parser TokenType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Not a token type"
  parseJSON Value
_ = Parser TokenType
forall a. Monoid a => a
mempty

-- | JSON @"Keyword"@ corresponds to 'KeywordTok', and so on.
instance FromJSONKey TokenType where
  fromJSONKey :: FromJSONKeyFunction TokenType
fromJSONKey = (Text -> Parser TokenType) -> FromJSONKeyFunction TokenType
forall a. (Text -> Parser a) -> FromJSONKeyFunction a
FromJSONKeyTextParser (\Text
t ->
    case String -> Maybe TokenType
forall a. Read a => String -> Maybe a
readMay (Text -> String
Text.unpack Text
t String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"Tok") of
         Just TokenType
tt -> TokenType -> Parser TokenType
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TokenType
tt
         Maybe TokenType
Nothing -> String -> Parser TokenType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Not a token type")

-- | A line of source: a list of labeled tokens.
type SourceLine = [Token]

-- | Line numbers
newtype LineNo = LineNo { LineNo -> Int
lineNo :: Int } deriving (Int -> LineNo -> ShowS
[LineNo] -> ShowS
LineNo -> String
(Int -> LineNo -> ShowS)
-> (LineNo -> String) -> ([LineNo] -> ShowS) -> Show LineNo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LineNo -> ShowS
showsPrec :: Int -> LineNo -> ShowS
$cshow :: LineNo -> String
show :: LineNo -> String
$cshowList :: [LineNo] -> ShowS
showList :: [LineNo] -> ShowS
Show, Int -> LineNo
LineNo -> Int
LineNo -> [LineNo]
LineNo -> LineNo
LineNo -> LineNo -> [LineNo]
LineNo -> LineNo -> LineNo -> [LineNo]
(LineNo -> LineNo)
-> (LineNo -> LineNo)
-> (Int -> LineNo)
-> (LineNo -> Int)
-> (LineNo -> [LineNo])
-> (LineNo -> LineNo -> [LineNo])
-> (LineNo -> LineNo -> [LineNo])
-> (LineNo -> LineNo -> LineNo -> [LineNo])
-> Enum LineNo
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: LineNo -> LineNo
succ :: LineNo -> LineNo
$cpred :: LineNo -> LineNo
pred :: LineNo -> LineNo
$ctoEnum :: Int -> LineNo
toEnum :: Int -> LineNo
$cfromEnum :: LineNo -> Int
fromEnum :: LineNo -> Int
$cenumFrom :: LineNo -> [LineNo]
enumFrom :: LineNo -> [LineNo]
$cenumFromThen :: LineNo -> LineNo -> [LineNo]
enumFromThen :: LineNo -> LineNo -> [LineNo]
$cenumFromTo :: LineNo -> LineNo -> [LineNo]
enumFromTo :: LineNo -> LineNo -> [LineNo]
$cenumFromThenTo :: LineNo -> LineNo -> LineNo -> [LineNo]
enumFromThenTo :: LineNo -> LineNo -> LineNo -> [LineNo]
Enum)

-- | A 'TokenStyle' determines how a token is to be rendered.
data TokenStyle = TokenStyle {
    TokenStyle -> Maybe Color
tokenColor      :: !(Maybe Color)
  , TokenStyle -> Maybe Color
tokenBackground :: !(Maybe Color)
  , TokenStyle -> Bool
tokenBold       :: !Bool
  , TokenStyle -> Bool
tokenItalic     :: !Bool
  , TokenStyle -> Bool
tokenUnderline  :: !Bool
  } deriving (Int -> TokenStyle -> ShowS
[TokenStyle] -> ShowS
TokenStyle -> String
(Int -> TokenStyle -> ShowS)
-> (TokenStyle -> String)
-> ([TokenStyle] -> ShowS)
-> Show TokenStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TokenStyle -> ShowS
showsPrec :: Int -> TokenStyle -> ShowS
$cshow :: TokenStyle -> String
show :: TokenStyle -> String
$cshowList :: [TokenStyle] -> ShowS
showList :: [TokenStyle] -> ShowS
Show, ReadPrec [TokenStyle]
ReadPrec TokenStyle
Int -> ReadS TokenStyle
ReadS [TokenStyle]
(Int -> ReadS TokenStyle)
-> ReadS [TokenStyle]
-> ReadPrec TokenStyle
-> ReadPrec [TokenStyle]
-> Read TokenStyle
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS TokenStyle
readsPrec :: Int -> ReadS TokenStyle
$creadList :: ReadS [TokenStyle]
readList :: ReadS [TokenStyle]
$creadPrec :: ReadPrec TokenStyle
readPrec :: ReadPrec TokenStyle
$creadListPrec :: ReadPrec [TokenStyle]
readListPrec :: ReadPrec [TokenStyle]
Read, Eq TokenStyle
Eq TokenStyle =>
(TokenStyle -> TokenStyle -> Ordering)
-> (TokenStyle -> TokenStyle -> Bool)
-> (TokenStyle -> TokenStyle -> Bool)
-> (TokenStyle -> TokenStyle -> Bool)
-> (TokenStyle -> TokenStyle -> Bool)
-> (TokenStyle -> TokenStyle -> TokenStyle)
-> (TokenStyle -> TokenStyle -> TokenStyle)
-> Ord TokenStyle
TokenStyle -> TokenStyle -> Bool
TokenStyle -> TokenStyle -> Ordering
TokenStyle -> TokenStyle -> TokenStyle
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TokenStyle -> TokenStyle -> Ordering
compare :: TokenStyle -> TokenStyle -> Ordering
$c< :: TokenStyle -> TokenStyle -> Bool
< :: TokenStyle -> TokenStyle -> Bool
$c<= :: TokenStyle -> TokenStyle -> Bool
<= :: TokenStyle -> TokenStyle -> Bool
$c> :: TokenStyle -> TokenStyle -> Bool
> :: TokenStyle -> TokenStyle -> Bool
$c>= :: TokenStyle -> TokenStyle -> Bool
>= :: TokenStyle -> TokenStyle -> Bool
$cmax :: TokenStyle -> TokenStyle -> TokenStyle
max :: TokenStyle -> TokenStyle -> TokenStyle
$cmin :: TokenStyle -> TokenStyle -> TokenStyle
min :: TokenStyle -> TokenStyle -> TokenStyle
Ord, TokenStyle -> TokenStyle -> Bool
(TokenStyle -> TokenStyle -> Bool)
-> (TokenStyle -> TokenStyle -> Bool) -> Eq TokenStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TokenStyle -> TokenStyle -> Bool
== :: TokenStyle -> TokenStyle -> Bool
$c/= :: TokenStyle -> TokenStyle -> Bool
/= :: TokenStyle -> TokenStyle -> Bool
Eq, Typeable TokenStyle
Typeable TokenStyle =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> TokenStyle -> c TokenStyle)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TokenStyle)
-> (TokenStyle -> Constr)
-> (TokenStyle -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TokenStyle))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c TokenStyle))
-> ((forall b. Data b => b -> b) -> TokenStyle -> TokenStyle)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TokenStyle -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TokenStyle -> r)
-> (forall u. (forall d. Data d => d -> u) -> TokenStyle -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TokenStyle -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle)
-> Data TokenStyle
TokenStyle -> Constr
TokenStyle -> DataType
(forall b. Data b => b -> b) -> TokenStyle -> TokenStyle
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) -> TokenStyle -> u
forall u. (forall d. Data d => d -> u) -> TokenStyle -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenStyle -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenStyle -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenStyle
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenStyle -> c TokenStyle
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenStyle)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenStyle)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenStyle -> c TokenStyle
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TokenStyle -> c TokenStyle
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenStyle
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TokenStyle
$ctoConstr :: TokenStyle -> Constr
toConstr :: TokenStyle -> Constr
$cdataTypeOf :: TokenStyle -> DataType
dataTypeOf :: TokenStyle -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenStyle)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TokenStyle)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenStyle)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TokenStyle)
$cgmapT :: (forall b. Data b => b -> b) -> TokenStyle -> TokenStyle
gmapT :: (forall b. Data b => b -> b) -> TokenStyle -> TokenStyle
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenStyle -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TokenStyle -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenStyle -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TokenStyle -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TokenStyle -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TokenStyle -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TokenStyle -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TokenStyle -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TokenStyle -> m TokenStyle
Data, Typeable, (forall x. TokenStyle -> Rep TokenStyle x)
-> (forall x. Rep TokenStyle x -> TokenStyle) -> Generic TokenStyle
forall x. Rep TokenStyle x -> TokenStyle
forall x. TokenStyle -> Rep TokenStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TokenStyle -> Rep TokenStyle x
from :: forall x. TokenStyle -> Rep TokenStyle x
$cto :: forall x. Rep TokenStyle x -> TokenStyle
to :: forall x. Rep TokenStyle x -> TokenStyle
Generic)

instance Binary TokenStyle

-- | The keywords used in KDE syntax
-- themes are used, e.g. @text-color@ for default token color.
instance FromJSON TokenStyle where
  parseJSON :: Value -> Parser TokenStyle
parseJSON (Object Object
v) = do
    Maybe Color
tcolor <- Object
v Object -> Key -> Parser (Maybe Color)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"text-color"
    Maybe Color
bg <- Object
v Object -> Key -> Parser (Maybe Color)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"background-color"
    Bool
tbold <- Object
v Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"bold" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
    Bool
titalic <- Object
v Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"italic" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
    Bool
tunderline <- Object
v Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"underline" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
    TokenStyle -> Parser TokenStyle
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TokenStyle{
               tokenColor :: Maybe Color
tokenColor = Maybe Color
tcolor
             , tokenBackground :: Maybe Color
tokenBackground = Maybe Color
bg
             , tokenBold :: Bool
tokenBold = Bool
tbold
             , tokenItalic :: Bool
tokenItalic = Bool
titalic
             , tokenUnderline :: Bool
tokenUnderline = Bool
tunderline }
  parseJSON Value
_ = Parser TokenStyle
forall a. Monoid a => a
mempty
instance ToJSON TokenStyle where
  toJSON :: TokenStyle -> Value
toJSON TokenStyle
ts = [Pair] -> Value
object [ Key
"text-color" Key -> Maybe Color -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TokenStyle -> Maybe Color
tokenColor TokenStyle
ts
                     , Key
"background-color" Key -> Maybe Color -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TokenStyle -> Maybe Color
tokenBackground TokenStyle
ts
                     , Key
"bold" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TokenStyle -> Bool
tokenBold TokenStyle
ts
                     , Key
"italic" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TokenStyle -> Bool
tokenItalic TokenStyle
ts
                     , Key
"underline" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TokenStyle -> Bool
tokenUnderline TokenStyle
ts ]

-- | Default style.
defStyle :: TokenStyle
defStyle :: TokenStyle
defStyle = TokenStyle {
    tokenColor :: Maybe Color
tokenColor      = Maybe Color
forall a. Maybe a
Nothing
  , tokenBackground :: Maybe Color
tokenBackground = Maybe Color
forall a. Maybe a
Nothing
  , tokenBold :: Bool
tokenBold       = Bool
False
  , tokenItalic :: Bool
tokenItalic     = Bool
False
  , tokenUnderline :: Bool
tokenUnderline  = Bool
False
  }

-- | A color (red, green, blue).
data Color = RGB Word8 Word8 Word8
  deriving (Int -> Color -> ShowS
[Color] -> ShowS
Color -> String
(Int -> Color -> ShowS)
-> (Color -> String) -> ([Color] -> ShowS) -> Show Color
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Color -> ShowS
showsPrec :: Int -> Color -> ShowS
$cshow :: Color -> String
show :: Color -> String
$cshowList :: [Color] -> ShowS
showList :: [Color] -> ShowS
Show, ReadPrec [Color]
ReadPrec Color
Int -> ReadS Color
ReadS [Color]
(Int -> ReadS Color)
-> ReadS [Color]
-> ReadPrec Color
-> ReadPrec [Color]
-> Read Color
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Color
readsPrec :: Int -> ReadS Color
$creadList :: ReadS [Color]
readList :: ReadS [Color]
$creadPrec :: ReadPrec Color
readPrec :: ReadPrec Color
$creadListPrec :: ReadPrec [Color]
readListPrec :: ReadPrec [Color]
Read, Eq Color
Eq Color =>
(Color -> Color -> Ordering)
-> (Color -> Color -> Bool)
-> (Color -> Color -> Bool)
-> (Color -> Color -> Bool)
-> (Color -> Color -> Bool)
-> (Color -> Color -> Color)
-> (Color -> Color -> Color)
-> Ord Color
Color -> Color -> Bool
Color -> Color -> Ordering
Color -> Color -> Color
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Color -> Color -> Ordering
compare :: Color -> Color -> Ordering
$c< :: Color -> Color -> Bool
< :: Color -> Color -> Bool
$c<= :: Color -> Color -> Bool
<= :: Color -> Color -> Bool
$c> :: Color -> Color -> Bool
> :: Color -> Color -> Bool
$c>= :: Color -> Color -> Bool
>= :: Color -> Color -> Bool
$cmax :: Color -> Color -> Color
max :: Color -> Color -> Color
$cmin :: Color -> Color -> Color
min :: Color -> Color -> Color
Ord, Color -> Color -> Bool
(Color -> Color -> Bool) -> (Color -> Color -> Bool) -> Eq Color
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Color -> Color -> Bool
== :: Color -> Color -> Bool
$c/= :: Color -> Color -> Bool
/= :: Color -> Color -> Bool
Eq, Typeable Color
Typeable Color =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Color -> c Color)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Color)
-> (Color -> Constr)
-> (Color -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Color))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Color))
-> ((forall b. Data b => b -> b) -> Color -> Color)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r)
-> (forall u. (forall d. Data d => d -> u) -> Color -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Color -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Color -> m Color)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Color -> m Color)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Color -> m Color)
-> Data Color
Color -> Constr
Color -> DataType
(forall b. Data b => b -> b) -> Color -> Color
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) -> Color -> u
forall u. (forall d. Data d => d -> u) -> Color -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Color -> m Color
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Color -> m Color
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Color
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Color -> c Color
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Color)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Color)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Color -> c Color
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Color -> c Color
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Color
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Color
$ctoConstr :: Color -> Constr
toConstr :: Color -> Constr
$cdataTypeOf :: Color -> DataType
dataTypeOf :: Color -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Color)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Color)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Color)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Color)
$cgmapT :: (forall b. Data b => b -> b) -> Color -> Color
gmapT :: (forall b. Data b => b -> b) -> Color -> Color
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Color -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Color -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Color -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Color -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Color -> m Color
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Color -> m Color
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Color -> m Color
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Color -> m Color
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Color -> m Color
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Color -> m Color
Data, Typeable, (forall x. Color -> Rep Color x)
-> (forall x. Rep Color x -> Color) -> Generic Color
forall x. Rep Color x -> Color
forall x. Color -> Rep Color x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Color -> Rep Color x
from :: forall x. Color -> Rep Color x
$cto :: forall x. Rep Color x -> Color
to :: forall x. Rep Color x -> Color
Generic)

instance Binary Color

-- | Things that can be converted to a color.
class ToColor a where
  toColor :: a -> Maybe Color

instance ToColor String where
  toColor :: String -> Maybe Color
toColor [Char
'#',Char
r1,Char
r2,Char
g1,Char
g2,Char
b1,Char
b2] =
     case ReadS (Word8, Word8, Word8)
forall a. Read a => ReadS a
reads [Char
'(',Char
'0',Char
'x',Char
r1,Char
r2,Char
',',Char
'0',Char
'x',Char
g1,Char
g2,Char
',',Char
'0',Char
'x',Char
b1,Char
b2,Char
')'] of
           ((Word8
r,Word8
g,Word8
b),String
_) : [((Word8, Word8, Word8), String)]
_ -> Color -> Maybe Color
forall a. a -> Maybe a
Just (Color -> Maybe Color) -> Color -> Maybe Color
forall a b. (a -> b) -> a -> b
$ Word8 -> Word8 -> Word8 -> Color
RGB Word8
r Word8
g Word8
b
           [((Word8, Word8, Word8), String)]
_               -> Maybe Color
forall a. Maybe a
Nothing
  toColor [Char
'#',Char
_,Char
_,Char
r1,Char
r2,Char
g1,Char
g2,Char
b1,Char
b2] = -- ARGB format, we just ignore the A
     case ReadS (Word8, Word8, Word8)
forall a. Read a => ReadS a
reads [Char
'(',Char
'0',Char
'x',Char
r1,Char
r2,Char
',',Char
'0',Char
'x',Char
g1,Char
g2,Char
',',Char
'0',Char
'x',Char
b1,Char
b2,Char
')'] of
           ((Word8
r,Word8
g,Word8
b),String
_) : [((Word8, Word8, Word8), String)]
_ -> Color -> Maybe Color
forall a. a -> Maybe a
Just (Color -> Maybe Color) -> Color -> Maybe Color
forall a b. (a -> b) -> a -> b
$ Word8 -> Word8 -> Word8 -> Color
RGB Word8
r Word8
g Word8
b
           [((Word8, Word8, Word8), String)]
_               -> Maybe Color
forall a. Maybe a
Nothing
  toColor String
_        = Maybe Color
forall a. Maybe a
Nothing

instance ToColor Int where
  toColor :: Int -> Maybe Color
toColor Int
x = (Word8, Word8, Word8) -> Maybe Color
forall a. ToColor a => a -> Maybe Color
toColor (Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x1 :: Word8,
                       Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x2 :: Word8,
                       Int -> Word8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x3 :: Word8)
    where x1 :: Int
x1 = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
shiftR Int
x Int
16) Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
0xFF
          x2 :: Int
x2 = (Int -> Int -> Int
forall a. Bits a => a -> Int -> a
shiftR Int
x Int
8 ) Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
0xFF
          x3 :: Int
x3 = Int
x             Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
0xFF

instance ToColor (Word8, Word8, Word8) where
  toColor :: (Word8, Word8, Word8) -> Maybe Color
toColor (Word8
r,Word8
g,Word8
b) = Color -> Maybe Color
forall a. a -> Maybe a
Just (Color -> Maybe Color) -> Color -> Maybe Color
forall a b. (a -> b) -> a -> b
$ Word8 -> Word8 -> Word8 -> Color
RGB Word8
r Word8
g Word8
b

instance ToColor (Double, Double, Double) where
  toColor :: (Double, Double, Double) -> Maybe Color
toColor (Double
r,Double
g,Double
b) | Double
r Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0 Bool -> Bool -> Bool
&& Double
g Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0 Bool -> Bool -> Bool
&& Double
b Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
>= Double
0 Bool -> Bool -> Bool
&& Double
r Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Double
1 Bool -> Bool -> Bool
&& Double
g Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Double
1 Bool -> Bool -> Bool
&& Double
b Double -> Double -> Bool
forall a. Ord a => a -> a -> Bool
<= Double
1 =
          Color -> Maybe Color
forall a. a -> Maybe a
Just (Color -> Maybe Color) -> Color -> Maybe Color
forall a b. (a -> b) -> a -> b
$ Word8 -> Word8 -> Word8 -> Color
RGB (Double -> Word8
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (Double -> Word8) -> Double -> Word8
forall a b. (a -> b) -> a -> b
$ Double
r Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
255) (Double -> Word8
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (Double -> Word8) -> Double -> Word8
forall a b. (a -> b) -> a -> b
$ Double
g Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
255) (Double -> Word8
forall b. Integral b => Double -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (Double -> Word8) -> Double -> Word8
forall a b. (a -> b) -> a -> b
$ Double
b Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
255)
  toColor (Double, Double, Double)
_ = Maybe Color
forall a. Maybe a
Nothing

instance (RealFrac a, Floating a) => ToColor (Colour a) where
    toColor :: Colour a -> Maybe Color
toColor Colour a
c = let (Colour.RGB Word8
r Word8
g Word8
b) = Colour a -> RGB Word8
forall b. (RealFrac b, Floating b) => Colour b -> RGB Word8
toSRGB24 Colour a
c in (Word8, Word8, Word8) -> Maybe Color
forall a. ToColor a => a -> Maybe Color
toColor (Word8
r, Word8
g, Word8
b)

-- | JSON @"#1aff2b"@ corresponds to the color @RGB 0x1a 0xff 0x2b@.
instance FromJSON Color where
  parseJSON :: Value -> Parser Color
parseJSON (String Text
t) = Parser Color
-> (Color -> Parser Color) -> Maybe Color -> Parser Color
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Parser Color
forall a. Monoid a => a
mempty Color -> Parser Color
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Color -> Parser Color) -> Maybe Color -> Parser Color
forall a b. (a -> b) -> a -> b
$ String -> Maybe Color
forall a. ToColor a => a -> Maybe Color
toColor (Text -> String
Text.unpack Text
t)
  parseJSON Value
_          = Parser Color
forall a. Monoid a => a
mempty

instance ToJSON Color where
  toJSON :: Color -> Value
toJSON Color
color = Text -> Value
String (String -> Text
Text.pack (Color -> String
forall a. FromColor a => Color -> a
fromColor Color
color :: String))

-- | Different representations of a 'Color'.
class FromColor a where
  fromColor :: Color -> a

instance FromColor String where
  fromColor :: Color -> String
fromColor (RGB Word8
r Word8
g Word8
b) = String -> Word8 -> Word8 -> Word8 -> String
forall r. PrintfType r => String -> r
printf String
"#%02x%02x%02x" Word8
r Word8
g Word8
b

instance FromColor (Double, Double, Double) where
  fromColor :: Color -> (Double, Double, Double)
fromColor (RGB Word8
r Word8
g Word8
b) = (Word8 -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
r Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
255, Word8 -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
g Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
255, Word8 -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word8
b Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/ Double
255)

instance FromColor (Word8, Word8, Word8) where
  fromColor :: Color -> (Word8, Word8, Word8)
fromColor (RGB Word8
r Word8
g Word8
b) = (Word8
r, Word8
g, Word8
b)

instance (Ord a, Floating a) => FromColor (Colour a) where
    fromColor :: Color -> Colour a
fromColor (RGB Word8
r Word8
g Word8
b) = Word8 -> Word8 -> Word8 -> Colour a
forall b.
(Ord b, Floating b) =>
Word8 -> Word8 -> Word8 -> Colour b
sRGB24 Word8
r Word8
g Word8
b

-- | A rendering style. This determines how each kind of token
-- is to be rendered, and sets a default color and background
-- color for normal tokens.  Line numbers can have a different
-- color and background color.
data Style = Style {
    Style -> Map TokenType TokenStyle
tokenStyles               :: !(Map.Map TokenType TokenStyle)
  , Style -> Maybe Color
defaultColor              :: !(Maybe Color)
  , Style -> Maybe Color
backgroundColor           :: !(Maybe Color)
  , Style -> Maybe Color
lineNumberColor           :: !(Maybe Color)
  , Style -> Maybe Color
lineNumberBackgroundColor :: !(Maybe Color)
  } deriving (ReadPrec [Style]
ReadPrec Style
Int -> ReadS Style
ReadS [Style]
(Int -> ReadS Style)
-> ReadS [Style]
-> ReadPrec Style
-> ReadPrec [Style]
-> Read Style
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Style
readsPrec :: Int -> ReadS Style
$creadList :: ReadS [Style]
readList :: ReadS [Style]
$creadPrec :: ReadPrec Style
readPrec :: ReadPrec Style
$creadListPrec :: ReadPrec [Style]
readListPrec :: ReadPrec [Style]
Read, Int -> Style -> ShowS
[Style] -> ShowS
Style -> String
(Int -> Style -> ShowS)
-> (Style -> String) -> ([Style] -> ShowS) -> Show Style
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Style -> ShowS
showsPrec :: Int -> Style -> ShowS
$cshow :: Style -> String
show :: Style -> String
$cshowList :: [Style] -> ShowS
showList :: [Style] -> ShowS
Show, Style -> Style -> Bool
(Style -> Style -> Bool) -> (Style -> Style -> Bool) -> Eq Style
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Style -> Style -> Bool
== :: Style -> Style -> Bool
$c/= :: Style -> Style -> Bool
/= :: Style -> Style -> Bool
Eq, Eq Style
Eq Style =>
(Style -> Style -> Ordering)
-> (Style -> Style -> Bool)
-> (Style -> Style -> Bool)
-> (Style -> Style -> Bool)
-> (Style -> Style -> Bool)
-> (Style -> Style -> Style)
-> (Style -> Style -> Style)
-> Ord Style
Style -> Style -> Bool
Style -> Style -> Ordering
Style -> Style -> Style
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Style -> Style -> Ordering
compare :: Style -> Style -> Ordering
$c< :: Style -> Style -> Bool
< :: Style -> Style -> Bool
$c<= :: Style -> Style -> Bool
<= :: Style -> Style -> Bool
$c> :: Style -> Style -> Bool
> :: Style -> Style -> Bool
$c>= :: Style -> Style -> Bool
>= :: Style -> Style -> Bool
$cmax :: Style -> Style -> Style
max :: Style -> Style -> Style
$cmin :: Style -> Style -> Style
min :: Style -> Style -> Style
Ord, Typeable Style
Typeable Style =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Style -> c Style)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Style)
-> (Style -> Constr)
-> (Style -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Style))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style))
-> ((forall b. Data b => b -> b) -> Style -> Style)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r)
-> (forall u. (forall d. Data d => d -> u) -> Style -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Style -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Style -> m Style)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Style -> m Style)
-> Data Style
Style -> Constr
Style -> DataType
(forall b. Data b => b -> b) -> Style -> Style
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) -> Style -> u
forall u. (forall d. Data d => d -> u) -> Style -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Style -> m Style
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Style -> m Style
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Style
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Style -> c Style
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Style)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Style -> c Style
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Style -> c Style
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Style
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Style
$ctoConstr :: Style -> Constr
toConstr :: Style -> Constr
$cdataTypeOf :: Style -> DataType
dataTypeOf :: Style -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Style)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Style)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Style)
$cgmapT :: (forall b. Data b => b -> b) -> Style -> Style
gmapT :: (forall b. Data b => b -> b) -> Style -> Style
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Style -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Style -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Style -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Style -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Style -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Style -> m Style
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Style -> m Style
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Style -> m Style
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Style -> m Style
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Style -> m Style
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Style -> m Style
Data, Typeable, (forall x. Style -> Rep Style x)
-> (forall x. Rep Style x -> Style) -> Generic Style
forall x. Rep Style x -> Style
forall x. Style -> Rep Style x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Style -> Rep Style x
from :: forall x. Style -> Rep Style x
$cto :: forall x. Rep Style x -> Style
to :: forall x. Rep Style x -> Style
Generic)

instance Binary Style

-- | The FromJSON instance for 'Style' is designed so that
-- a KDE syntax theme (JSON) can be decoded directly as a
-- 'Style'.
instance FromJSON Style where
  parseJSON :: Value -> Parser Style
parseJSON (Object Object
v) = do
    (Map Text TokenStyle
tokstyles :: Map.Map Text TokenStyle) <- Object
v Object -> Key -> Parser (Map Text TokenStyle)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"text-styles"
    (Map Text Color
editorColors :: Map.Map Text Color) <- Object
v Object -> Key -> Parser (Maybe (Map Text Color))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"editor-colors" Parser (Maybe (Map Text Color))
-> Map Text Color -> Parser (Map Text Color)
forall a. Parser (Maybe a) -> a -> Parser a
.!= Map Text Color
forall a. Monoid a => a
mempty
    Maybe Color
mbBackgroundColor <- Object
v Object -> Key -> Parser (Maybe Color)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"background-color"
    Maybe Color
mbLineNumberColor <- Object
v Object -> Key -> Parser (Maybe Color)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"line-number-color"
    Maybe Color
mbDefaultColor <- Object
v Object -> Key -> Parser (Maybe Color)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"text-color"
    Maybe Color
mbLineNumberBackgroundColor <- Object
v Object -> Key -> Parser (Maybe Color)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"line-number-background-color"
    Style -> Parser Style
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return Style{ defaultColor :: Maybe Color
defaultColor = Maybe Color
mbDefaultColor Maybe Color -> Maybe Color -> Maybe Color
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
                     (case Text -> Map Text TokenStyle -> Maybe TokenStyle
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
"Normal" Map Text TokenStyle
tokstyles of
                           Maybe TokenStyle
Nothing -> Maybe Color
forall a. Maybe a
Nothing
                           Just TokenStyle
ts -> TokenStyle -> Maybe Color
tokenColor TokenStyle
ts)
                , backgroundColor :: Maybe Color
backgroundColor = Maybe Color
mbBackgroundColor Maybe Color -> Maybe Color -> Maybe Color
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
                     Text -> Map Text Color -> Maybe Color
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
"background-color" Map Text Color
editorColors
                , lineNumberColor :: Maybe Color
lineNumberColor = Maybe Color
mbLineNumberColor Maybe Color -> Maybe Color -> Maybe Color
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
                     Text -> Map Text Color -> Maybe Color
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
"line-numbers" Map Text Color
editorColors
                , lineNumberBackgroundColor :: Maybe Color
lineNumberBackgroundColor =
                     Maybe Color
mbLineNumberBackgroundColor Maybe Color -> Maybe Color -> Maybe Color
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus`
                       Text -> Map Text Color -> Maybe Color
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup Text
"background-color" Map Text Color
editorColors
                , tokenStyles :: Map TokenType TokenStyle
tokenStyles =
                     (Text -> TokenType)
-> Map Text TokenStyle -> Map TokenType TokenStyle
forall k2 k1 a. Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
Map.mapKeys (\Text
s -> TokenType
-> (TokenType -> TokenType) -> Maybe TokenType -> TokenType
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TokenType
OtherTok TokenType -> TokenType
forall a. a -> a
id (Maybe TokenType -> TokenType) -> Maybe TokenType -> TokenType
forall a b. (a -> b) -> a -> b
$
                                     String -> Maybe TokenType
forall a. Read a => String -> Maybe a
readMay (Text -> String
Text.unpack Text
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"Tok")) Map Text TokenStyle
tokstyles }
  parseJSON Value
_ = Parser Style
forall a. Monoid a => a
mempty

instance ToJSON Style where
  toJSON :: Style -> Value
toJSON Style
s = [Pair] -> Value
object [ Key
"text-styles" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Map TokenType TokenStyle -> Value
forall a. ToJSON a => a -> Value
toJSON (Style -> Map TokenType TokenStyle
tokenStyles Style
s)
                    , Key
"background-color" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Color -> Value
forall a. ToJSON a => a -> Value
toJSON (Style -> Maybe Color
backgroundColor Style
s)
                    , Key
"text-color" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Color -> Value
forall a. ToJSON a => a -> Value
toJSON (Style -> Maybe Color
defaultColor Style
s)
                    , Key
"line-number-color" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Color -> Value
forall a. ToJSON a => a -> Value
toJSON (Style -> Maybe Color
lineNumberColor Style
s)
                    , Key
"line-number-background-color" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.=
                         Maybe Color -> Value
forall a. ToJSON a => a -> Value
toJSON (Style -> Maybe Color
lineNumberBackgroundColor Style
s)
                    ]

-- | The available levels of color complexity in ANSI terminal output.
data ANSIColorLevel = ANSI16Color   -- ^ 16-color mode
                    | ANSI256Color  -- ^ 256-color mode
                    | ANSITrueColor -- ^ True-color mode
       deriving (Int -> ANSIColorLevel -> ShowS
[ANSIColorLevel] -> ShowS
ANSIColorLevel -> String
(Int -> ANSIColorLevel -> ShowS)
-> (ANSIColorLevel -> String)
-> ([ANSIColorLevel] -> ShowS)
-> Show ANSIColorLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ANSIColorLevel -> ShowS
showsPrec :: Int -> ANSIColorLevel -> ShowS
$cshow :: ANSIColorLevel -> String
show :: ANSIColorLevel -> String
$cshowList :: [ANSIColorLevel] -> ShowS
showList :: [ANSIColorLevel] -> ShowS
Show, ReadPrec [ANSIColorLevel]
ReadPrec ANSIColorLevel
Int -> ReadS ANSIColorLevel
ReadS [ANSIColorLevel]
(Int -> ReadS ANSIColorLevel)
-> ReadS [ANSIColorLevel]
-> ReadPrec ANSIColorLevel
-> ReadPrec [ANSIColorLevel]
-> Read ANSIColorLevel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS ANSIColorLevel
readsPrec :: Int -> ReadS ANSIColorLevel
$creadList :: ReadS [ANSIColorLevel]
readList :: ReadS [ANSIColorLevel]
$creadPrec :: ReadPrec ANSIColorLevel
readPrec :: ReadPrec ANSIColorLevel
$creadListPrec :: ReadPrec [ANSIColorLevel]
readListPrec :: ReadPrec [ANSIColorLevel]
Read, ANSIColorLevel -> ANSIColorLevel -> Bool
(ANSIColorLevel -> ANSIColorLevel -> Bool)
-> (ANSIColorLevel -> ANSIColorLevel -> Bool) -> Eq ANSIColorLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ANSIColorLevel -> ANSIColorLevel -> Bool
== :: ANSIColorLevel -> ANSIColorLevel -> Bool
$c/= :: ANSIColorLevel -> ANSIColorLevel -> Bool
/= :: ANSIColorLevel -> ANSIColorLevel -> Bool
Eq, Eq ANSIColorLevel
Eq ANSIColorLevel =>
(ANSIColorLevel -> ANSIColorLevel -> Ordering)
-> (ANSIColorLevel -> ANSIColorLevel -> Bool)
-> (ANSIColorLevel -> ANSIColorLevel -> Bool)
-> (ANSIColorLevel -> ANSIColorLevel -> Bool)
-> (ANSIColorLevel -> ANSIColorLevel -> Bool)
-> (ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel)
-> (ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel)
-> Ord ANSIColorLevel
ANSIColorLevel -> ANSIColorLevel -> Bool
ANSIColorLevel -> ANSIColorLevel -> Ordering
ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ANSIColorLevel -> ANSIColorLevel -> Ordering
compare :: ANSIColorLevel -> ANSIColorLevel -> Ordering
$c< :: ANSIColorLevel -> ANSIColorLevel -> Bool
< :: ANSIColorLevel -> ANSIColorLevel -> Bool
$c<= :: ANSIColorLevel -> ANSIColorLevel -> Bool
<= :: ANSIColorLevel -> ANSIColorLevel -> Bool
$c> :: ANSIColorLevel -> ANSIColorLevel -> Bool
> :: ANSIColorLevel -> ANSIColorLevel -> Bool
$c>= :: ANSIColorLevel -> ANSIColorLevel -> Bool
>= :: ANSIColorLevel -> ANSIColorLevel -> Bool
$cmax :: ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel
max :: ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel
$cmin :: ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel
min :: ANSIColorLevel -> ANSIColorLevel -> ANSIColorLevel
Ord, Int -> ANSIColorLevel
ANSIColorLevel -> Int
ANSIColorLevel -> [ANSIColorLevel]
ANSIColorLevel -> ANSIColorLevel
ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
ANSIColorLevel
-> ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
(ANSIColorLevel -> ANSIColorLevel)
-> (ANSIColorLevel -> ANSIColorLevel)
-> (Int -> ANSIColorLevel)
-> (ANSIColorLevel -> Int)
-> (ANSIColorLevel -> [ANSIColorLevel])
-> (ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel])
-> (ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel])
-> (ANSIColorLevel
    -> ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel])
-> Enum ANSIColorLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: ANSIColorLevel -> ANSIColorLevel
succ :: ANSIColorLevel -> ANSIColorLevel
$cpred :: ANSIColorLevel -> ANSIColorLevel
pred :: ANSIColorLevel -> ANSIColorLevel
$ctoEnum :: Int -> ANSIColorLevel
toEnum :: Int -> ANSIColorLevel
$cfromEnum :: ANSIColorLevel -> Int
fromEnum :: ANSIColorLevel -> Int
$cenumFrom :: ANSIColorLevel -> [ANSIColorLevel]
enumFrom :: ANSIColorLevel -> [ANSIColorLevel]
$cenumFromThen :: ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
enumFromThen :: ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
$cenumFromTo :: ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
enumFromTo :: ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
$cenumFromThenTo :: ANSIColorLevel
-> ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
enumFromThenTo :: ANSIColorLevel
-> ANSIColorLevel -> ANSIColorLevel -> [ANSIColorLevel]
Enum, ANSIColorLevel
ANSIColorLevel -> ANSIColorLevel -> Bounded ANSIColorLevel
forall a. a -> a -> Bounded a
$cminBound :: ANSIColorLevel
minBound :: ANSIColorLevel
$cmaxBound :: ANSIColorLevel
maxBound :: ANSIColorLevel
Bounded, Typeable ANSIColorLevel
Typeable ANSIColorLevel =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ANSIColorLevel -> c ANSIColorLevel)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ANSIColorLevel)
-> (ANSIColorLevel -> Constr)
-> (ANSIColorLevel -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ANSIColorLevel))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ANSIColorLevel))
-> ((forall b. Data b => b -> b)
    -> ANSIColorLevel -> ANSIColorLevel)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ANSIColorLevel -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ANSIColorLevel -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ANSIColorLevel -> m ANSIColorLevel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ANSIColorLevel -> m ANSIColorLevel)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ANSIColorLevel -> m ANSIColorLevel)
-> Data ANSIColorLevel
ANSIColorLevel -> Constr
ANSIColorLevel -> DataType
(forall b. Data b => b -> b) -> ANSIColorLevel -> ANSIColorLevel
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) -> ANSIColorLevel -> u
forall u. (forall d. Data d => d -> u) -> ANSIColorLevel -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ANSIColorLevel
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ANSIColorLevel -> c ANSIColorLevel
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ANSIColorLevel)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ANSIColorLevel)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ANSIColorLevel -> c ANSIColorLevel
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ANSIColorLevel -> c ANSIColorLevel
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ANSIColorLevel
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ANSIColorLevel
$ctoConstr :: ANSIColorLevel -> Constr
toConstr :: ANSIColorLevel -> Constr
$cdataTypeOf :: ANSIColorLevel -> DataType
dataTypeOf :: ANSIColorLevel -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ANSIColorLevel)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ANSIColorLevel)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ANSIColorLevel)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ANSIColorLevel)
$cgmapT :: (forall b. Data b => b -> b) -> ANSIColorLevel -> ANSIColorLevel
gmapT :: (forall b. Data b => b -> b) -> ANSIColorLevel -> ANSIColorLevel
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ANSIColorLevel -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ANSIColorLevel -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ANSIColorLevel -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ANSIColorLevel -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ANSIColorLevel -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ANSIColorLevel -> m ANSIColorLevel
Data, Typeable, (forall x. ANSIColorLevel -> Rep ANSIColorLevel x)
-> (forall x. Rep ANSIColorLevel x -> ANSIColorLevel)
-> Generic ANSIColorLevel
forall x. Rep ANSIColorLevel x -> ANSIColorLevel
forall x. ANSIColorLevel -> Rep ANSIColorLevel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ANSIColorLevel -> Rep ANSIColorLevel x
from :: forall x. ANSIColorLevel -> Rep ANSIColorLevel x
$cto :: forall x. Rep ANSIColorLevel x -> ANSIColorLevel
to :: forall x. Rep ANSIColorLevel x -> ANSIColorLevel
Generic)

instance Binary ANSIColorLevel

-- | Options for formatting source code.
data FormatOptions = FormatOptions{
         FormatOptions -> Bool
numberLines      :: !Bool           -- ^ Number lines
       , FormatOptions -> Int
startNumber      :: !Int            -- ^ Number of first line
       , FormatOptions -> Bool
lineAnchors      :: !Bool           -- ^ Anchors on each line number
       , FormatOptions -> Bool
titleAttributes  :: !Bool           -- ^ Html titles with token types
       , FormatOptions -> [Text]
codeClasses      :: ![Text]         -- ^ Additional classes for Html code tag
       , FormatOptions -> [Text]
containerClasses :: ![Text]         -- ^ Additional classes for Html container tag
       , FormatOptions -> Text
lineIdPrefix     :: !Text           -- ^ Prefix for id attributes on lines
       , FormatOptions -> ANSIColorLevel
ansiColorLevel   :: !ANSIColorLevel -- ^ Level of ANSI color support to use
       } deriving (Int -> FormatOptions -> ShowS
[FormatOptions] -> ShowS
FormatOptions -> String
(Int -> FormatOptions -> ShowS)
-> (FormatOptions -> String)
-> ([FormatOptions] -> ShowS)
-> Show FormatOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FormatOptions -> ShowS
showsPrec :: Int -> FormatOptions -> ShowS
$cshow :: FormatOptions -> String
show :: FormatOptions -> String
$cshowList :: [FormatOptions] -> ShowS
showList :: [FormatOptions] -> ShowS
Show, ReadPrec [FormatOptions]
ReadPrec FormatOptions
Int -> ReadS FormatOptions
ReadS [FormatOptions]
(Int -> ReadS FormatOptions)
-> ReadS [FormatOptions]
-> ReadPrec FormatOptions
-> ReadPrec [FormatOptions]
-> Read FormatOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS FormatOptions
readsPrec :: Int -> ReadS FormatOptions
$creadList :: ReadS [FormatOptions]
readList :: ReadS [FormatOptions]
$creadPrec :: ReadPrec FormatOptions
readPrec :: ReadPrec FormatOptions
$creadListPrec :: ReadPrec [FormatOptions]
readListPrec :: ReadPrec [FormatOptions]
Read, FormatOptions -> FormatOptions -> Bool
(FormatOptions -> FormatOptions -> Bool)
-> (FormatOptions -> FormatOptions -> Bool) -> Eq FormatOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FormatOptions -> FormatOptions -> Bool
== :: FormatOptions -> FormatOptions -> Bool
$c/= :: FormatOptions -> FormatOptions -> Bool
/= :: FormatOptions -> FormatOptions -> Bool
Eq, Eq FormatOptions
Eq FormatOptions =>
(FormatOptions -> FormatOptions -> Ordering)
-> (FormatOptions -> FormatOptions -> Bool)
-> (FormatOptions -> FormatOptions -> Bool)
-> (FormatOptions -> FormatOptions -> Bool)
-> (FormatOptions -> FormatOptions -> Bool)
-> (FormatOptions -> FormatOptions -> FormatOptions)
-> (FormatOptions -> FormatOptions -> FormatOptions)
-> Ord FormatOptions
FormatOptions -> FormatOptions -> Bool
FormatOptions -> FormatOptions -> Ordering
FormatOptions -> FormatOptions -> FormatOptions
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FormatOptions -> FormatOptions -> Ordering
compare :: FormatOptions -> FormatOptions -> Ordering
$c< :: FormatOptions -> FormatOptions -> Bool
< :: FormatOptions -> FormatOptions -> Bool
$c<= :: FormatOptions -> FormatOptions -> Bool
<= :: FormatOptions -> FormatOptions -> Bool
$c> :: FormatOptions -> FormatOptions -> Bool
> :: FormatOptions -> FormatOptions -> Bool
$c>= :: FormatOptions -> FormatOptions -> Bool
>= :: FormatOptions -> FormatOptions -> Bool
$cmax :: FormatOptions -> FormatOptions -> FormatOptions
max :: FormatOptions -> FormatOptions -> FormatOptions
$cmin :: FormatOptions -> FormatOptions -> FormatOptions
min :: FormatOptions -> FormatOptions -> FormatOptions
Ord, Typeable FormatOptions
Typeable FormatOptions =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> FormatOptions -> c FormatOptions)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FormatOptions)
-> (FormatOptions -> Constr)
-> (FormatOptions -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FormatOptions))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c FormatOptions))
-> ((forall b. Data b => b -> b) -> FormatOptions -> FormatOptions)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> FormatOptions -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> FormatOptions -> r)
-> (forall u. (forall d. Data d => d -> u) -> FormatOptions -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> FormatOptions -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions)
-> Data FormatOptions
FormatOptions -> Constr
FormatOptions -> DataType
(forall b. Data b => b -> b) -> FormatOptions -> FormatOptions
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) -> FormatOptions -> u
forall u. (forall d. Data d => d -> u) -> FormatOptions -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FormatOptions -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FormatOptions -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FormatOptions
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FormatOptions -> c FormatOptions
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FormatOptions)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FormatOptions)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FormatOptions -> c FormatOptions
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FormatOptions -> c FormatOptions
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FormatOptions
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FormatOptions
$ctoConstr :: FormatOptions -> Constr
toConstr :: FormatOptions -> Constr
$cdataTypeOf :: FormatOptions -> DataType
dataTypeOf :: FormatOptions -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FormatOptions)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FormatOptions)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FormatOptions)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FormatOptions)
$cgmapT :: (forall b. Data b => b -> b) -> FormatOptions -> FormatOptions
gmapT :: (forall b. Data b => b -> b) -> FormatOptions -> FormatOptions
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FormatOptions -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FormatOptions -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FormatOptions -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FormatOptions -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FormatOptions -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> FormatOptions -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FormatOptions -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FormatOptions -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FormatOptions -> m FormatOptions
Data, Typeable, (forall x. FormatOptions -> Rep FormatOptions x)
-> (forall x. Rep FormatOptions x -> FormatOptions)
-> Generic FormatOptions
forall x. Rep FormatOptions x -> FormatOptions
forall x. FormatOptions -> Rep FormatOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FormatOptions -> Rep FormatOptions x
from :: forall x. FormatOptions -> Rep FormatOptions x
$cto :: forall x. Rep FormatOptions x -> FormatOptions
to :: forall x. Rep FormatOptions x -> FormatOptions
Generic)

instance Binary FormatOptions

-- | Default formatting options.
defaultFormatOpts :: FormatOptions
defaultFormatOpts :: FormatOptions
defaultFormatOpts = FormatOptions{
                      numberLines :: Bool
numberLines = Bool
False
                    , startNumber :: Int
startNumber = Int
1
                    , lineAnchors :: Bool
lineAnchors = Bool
False
                    , titleAttributes :: Bool
titleAttributes = Bool
False
                    , codeClasses :: [Text]
codeClasses = []
                    , containerClasses :: [Text]
containerClasses = []
                    , lineIdPrefix :: Text
lineIdPrefix = Text
""
                    , ansiColorLevel :: ANSIColorLevel
ansiColorLevel = ANSIColorLevel
ANSI16Color
                    }