{-# LANGUAGE ConstraintKinds       #-}
{-# LANGUAGE DataKinds             #-}
{-# LANGUAGE DeriveAnyClass        #-}
{-# LANGUAGE DeriveGeneric         #-}
{-# LANGUAGE DerivingVia           #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE GADTs                 #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds             #-}
{-# LANGUAGE PatternSynonyms       #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE StandaloneDeriving    #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE TypeOperators         #-}
{-# LANGUAGE UndecidableInstances  #-}

module Brassica.SoundChange.Types
       (
       -- * Words and graphemes
         Grapheme(..)
       , PWord
       , addBoundaries
       , removeBoundaries
       , concatWithBoundary
       -- * Lexemes
       , Lexeme(..)
       , pattern Boundary
       , LexemeType(..)
       , generalise
       -- * Categories
       , mapCategory
       , mapCategoryA
       , Expanded(..)
       , generaliseExpanded
       -- * Rules
       , Rule(..)
       , Environment
       , Direction(..)
       , Flags(..)
       , defFlags
       -- * Statements
       , Statement(..)
       , plaintext'
       , SoundChanges
       -- * Directives
       , CategoryModification(..)
       , CategorySpec(..)
       , FeatureSpec(..)
       , CategoryDefinition(..)
       , Directive(..)
       -- * Utility
       , OneOf
       ) where

import Control.DeepSeq (NFData(..))
import Data.Kind (Constraint)
import Data.String (IsString(..))
import GHC.Generics (Generic)
import GHC.OldList (dropWhileEnd)
import GHC.TypeLits

-- | The constraint @OneOf a x y@ is satisfied if @a ~ x@ or @a ~ y@.
--
-- (Note: the strange @() ~ Bool@ constraint is just a simple
-- unsatisfiable constraint, so as to not give ‘non-exhaustive pattern
-- match’ errors everywhere.)
type family OneOf a x y :: Constraint where
    OneOf a a y = ()
    OneOf a x a = ()
    OneOf a b c =
        ( () ~ Bool
        , TypeError ('Text "Couldn't match type "
                     ':<>: 'ShowType a
                     ':<>: 'Text " with "
                     ':<>: 'ShowType b
                     ':<>: 'Text " or "
                     ':<>: 'ShowType c))

-- | The type of graphemes within a word.
data Grapheme
    = GMulti [Char]  -- ^ A multigraph: for instance @GMulti "a", GMulti "ch", GMulti "c̓" :: t'Grapheme'@.
    | GBoundary      -- ^ A non-letter element representing a word boundary which sound changes can manipulate
    deriving (Grapheme -> Grapheme -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Grapheme -> Grapheme -> Bool
$c/= :: Grapheme -> Grapheme -> Bool
== :: Grapheme -> Grapheme -> Bool
$c== :: Grapheme -> Grapheme -> Bool
Eq, Eq Grapheme
Grapheme -> Grapheme -> Bool
Grapheme -> Grapheme -> Ordering
Grapheme -> Grapheme -> Grapheme
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
min :: Grapheme -> Grapheme -> Grapheme
$cmin :: Grapheme -> Grapheme -> Grapheme
max :: Grapheme -> Grapheme -> Grapheme
$cmax :: Grapheme -> Grapheme -> Grapheme
>= :: Grapheme -> Grapheme -> Bool
$c>= :: Grapheme -> Grapheme -> Bool
> :: Grapheme -> Grapheme -> Bool
$c> :: Grapheme -> Grapheme -> Bool
<= :: Grapheme -> Grapheme -> Bool
$c<= :: Grapheme -> Grapheme -> Bool
< :: Grapheme -> Grapheme -> Bool
$c< :: Grapheme -> Grapheme -> Bool
compare :: Grapheme -> Grapheme -> Ordering
$ccompare :: Grapheme -> Grapheme -> Ordering
Ord, Int -> Grapheme -> ShowS
[Grapheme] -> ShowS
Grapheme -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Grapheme] -> ShowS
$cshowList :: [Grapheme] -> ShowS
show :: Grapheme -> String
$cshow :: Grapheme -> String
showsPrec :: Int -> Grapheme -> ShowS
$cshowsPrec :: Int -> Grapheme -> ShowS
Show, forall x. Rep Grapheme x -> Grapheme
forall x. Grapheme -> Rep Grapheme x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Grapheme x -> Grapheme
$cfrom :: forall x. Grapheme -> Rep Grapheme x
Generic, Grapheme -> ()
forall a. (a -> ()) -> NFData a
rnf :: Grapheme -> ()
$crnf :: Grapheme -> ()
NFData)

instance IsString Grapheme where
    fromString :: String -> Grapheme
fromString = String -> Grapheme
GMulti

-- | A word (or a subsequence of one) can be viewed as a list of
-- @Grapheme@s: e.g. Portuguese "filha" becomes
-- @["f", "i", "lh", "a"] :: 'PWord'@.
--
-- (The name 'PWord' is from ‘phonological word’, these being what a
-- SCA typically manipulates; this name was chosen to avoid a clash
-- with @Prelude.'Prelude.Word'@.)
type PWord = [Grapheme]

-- Add a 'GBoundary' at the beginning and end of the 'PWord'.
addBoundaries :: PWord -> PWord
addBoundaries :: [Grapheme] -> [Grapheme]
addBoundaries [Grapheme]
w = Grapheme
GBoundary forall a. a -> [a] -> [a]
: [Grapheme]
w forall a. [a] -> [a] -> [a]
++ [Grapheme
GBoundary]

-- Remove 'GBoundary's from the beginning and end of the 'PWord'.
removeBoundaries :: PWord -> PWord
removeBoundaries :: [Grapheme] -> [Grapheme]
removeBoundaries = forall a. (a -> Bool) -> [a] -> [a]
dropWhile (forall a. Eq a => a -> a -> Bool
==Grapheme
GBoundary) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
dropWhileEnd (forall a. Eq a => a -> a -> Bool
==Grapheme
GBoundary)

-- | Render a 'PWord' as a 'String'. Very much like 'concat', but
-- treating 'GBoundary's specially. Word-external boundaries are
-- deleted, while word-internal boundaries are converted to @"#"@.
concatWithBoundary :: PWord -> String
concatWithBoundary :: [Grapheme] -> String
concatWithBoundary = [Grapheme] -> String
go forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Grapheme] -> [Grapheme]
removeBoundaries
  where
    go :: [Grapheme] -> String
go = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a b. (a -> b) -> a -> b
$ \case
        GMulti String
g -> String
g
        Grapheme
GBoundary -> String
"#"

-- | The part of a 'Rule' in which a 'Lexeme' may occur: either the
-- target, the replacement or the environment, or in any of those.
data LexemeType = Target | Replacement | Env | AnyPart

-- | A 'Lexeme' is the smallest part of a sound change. Both matches
-- and replacements are made up of 'Lexeme's: the phantom type
-- variable @a@ specifies where each different variety of 'Lexeme' may
-- occur. 'Lexeme's are also parameterised by their category type,
-- which may be 'Expanded' or something else.
data Lexeme category (a :: LexemeType) where
    -- | In Brassica sound-change syntax, one or more letters without intervening whitespace,
    -- or a word boundary specified as @#@
    Grapheme :: Grapheme -> Lexeme category a
    -- | In Brassica sound-change syntax, delimited by square brackets
    Category :: category a -> Lexeme category a
    -- | In Brassica sound-change syntax, delimited by parentheses
    Optional :: [Lexeme category a] -> Lexeme category a
    -- | In Brassica sound-change syntax, specified as @\@
    Metathesis :: Lexeme category 'Replacement
    -- | In Brassica sound-change syntax, specified as @>@
    Geminate :: Lexeme category a
    -- | In Brassica sound-change syntax, specified as @^@ before another 'Lexeme'
    Wildcard :: OneOf a 'Target 'Env => Lexeme category a -> Lexeme category a
    -- | In Brassica sound-change syntax, specified as @*@ after another 'Lexeme'
    Kleene   :: OneOf a 'Target 'Env => Lexeme category a -> Lexeme category a
    -- | In Brassica sound-change syntax, specified as @~@
    Discard  :: Lexeme category 'Replacement
    -- | In Brassica sound-change syntax, specified as \@i before a category
    Backreference :: Int -> category a -> Lexeme category a
    -- | In Brassica sound-change syntax, specified as \@? before a category
    Multiple :: category 'Replacement -> Lexeme category 'Replacement

mapCategory :: (forall x. c x -> c' x) -> Lexeme c a -> Lexeme c' a
mapCategory :: forall (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
(forall (x :: LexemeType). c x -> c' x)
-> Lexeme c a -> Lexeme c' a
mapCategory forall (x :: LexemeType). c x -> c' x
_ (Grapheme Grapheme
g) = forall (category :: LexemeType -> *) (a :: LexemeType).
Grapheme -> Lexeme category a
Grapheme Grapheme
g
mapCategory forall (x :: LexemeType). c x -> c' x
f (Category c a
c) = forall (category :: LexemeType -> *) (a :: LexemeType).
category a -> Lexeme category a
Category (forall (x :: LexemeType). c x -> c' x
f c a
c)
mapCategory forall (x :: LexemeType). c x -> c' x
f (Optional [Lexeme c a]
ls) = forall (category :: LexemeType -> *) (a :: LexemeType).
[Lexeme category a] -> Lexeme category a
Optional (forall (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
(forall (x :: LexemeType). c x -> c' x)
-> Lexeme c a -> Lexeme c' a
mapCategory forall (x :: LexemeType). c x -> c' x
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Lexeme c a]
ls)
mapCategory forall (x :: LexemeType). c x -> c' x
_ Lexeme c a
Metathesis = forall (category :: LexemeType -> *). Lexeme category 'Replacement
Metathesis
mapCategory forall (x :: LexemeType). c x -> c' x
_ Lexeme c a
Geminate = forall (category :: LexemeType -> *) (a :: LexemeType).
Lexeme category a
Geminate
mapCategory forall (x :: LexemeType). c x -> c' x
f (Wildcard Lexeme c a
l) = forall (a :: LexemeType) (category :: LexemeType -> *).
OneOf a 'Target 'Env =>
Lexeme category a -> Lexeme category a
Wildcard (forall (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
(forall (x :: LexemeType). c x -> c' x)
-> Lexeme c a -> Lexeme c' a
mapCategory forall (x :: LexemeType). c x -> c' x
f Lexeme c a
l)
mapCategory forall (x :: LexemeType). c x -> c' x
f (Kleene Lexeme c a
l) = forall (a :: LexemeType) (category :: LexemeType -> *).
OneOf a 'Target 'Env =>
Lexeme category a -> Lexeme category a
Kleene (forall (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
(forall (x :: LexemeType). c x -> c' x)
-> Lexeme c a -> Lexeme c' a
mapCategory forall (x :: LexemeType). c x -> c' x
f Lexeme c a
l)
mapCategory forall (x :: LexemeType). c x -> c' x
_ Lexeme c a
Discard = forall (category :: LexemeType -> *). Lexeme category 'Replacement
Discard
mapCategory forall (x :: LexemeType). c x -> c' x
f (Backreference Int
i c a
c) = forall (category :: LexemeType -> *) (a :: LexemeType).
Int -> category a -> Lexeme category a
Backreference Int
i (forall (x :: LexemeType). c x -> c' x
f c a
c)
mapCategory forall (x :: LexemeType). c x -> c' x
f (Multiple c 'Replacement
c) = forall (category :: LexemeType -> *).
category 'Replacement -> Lexeme category 'Replacement
Multiple (forall (x :: LexemeType). c x -> c' x
f c 'Replacement
c)

mapCategoryA
    :: Applicative t
    => (forall x. c x -> t (c' x))
    -> Lexeme c a
    -> t (Lexeme c' a)
mapCategoryA :: forall (t :: * -> *) (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
Applicative t =>
(forall (x :: LexemeType). c x -> t (c' x))
-> Lexeme c a -> t (Lexeme c' a)
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
_ (Grapheme Grapheme
g) = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (category :: LexemeType -> *) (a :: LexemeType).
Grapheme -> Lexeme category a
Grapheme Grapheme
g
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f (Category c a
c) = forall (category :: LexemeType -> *) (a :: LexemeType).
category a -> Lexeme category a
Category forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (x :: LexemeType). c x -> t (c' x)
f c a
c
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f (Optional [Lexeme c a]
ls) = forall (category :: LexemeType -> *) (a :: LexemeType).
[Lexeme category a] -> Lexeme category a
Optional forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
Applicative t =>
(forall (x :: LexemeType). c x -> t (c' x))
-> Lexeme c a -> t (Lexeme c' a)
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f) [Lexeme c a]
ls
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
_ Lexeme c a
Metathesis = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (category :: LexemeType -> *). Lexeme category 'Replacement
Metathesis
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
_ Lexeme c a
Geminate = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (category :: LexemeType -> *) (a :: LexemeType).
Lexeme category a
Geminate
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f (Wildcard Lexeme c a
l) = forall (a :: LexemeType) (category :: LexemeType -> *).
OneOf a 'Target 'Env =>
Lexeme category a -> Lexeme category a
Wildcard forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
Applicative t =>
(forall (x :: LexemeType). c x -> t (c' x))
-> Lexeme c a -> t (Lexeme c' a)
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f Lexeme c a
l
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f (Kleene Lexeme c a
l) = forall (a :: LexemeType) (category :: LexemeType -> *).
OneOf a 'Target 'Env =>
Lexeme category a -> Lexeme category a
Kleene forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (c :: LexemeType -> *) (c' :: LexemeType -> *)
       (a :: LexemeType).
Applicative t =>
(forall (x :: LexemeType). c x -> t (c' x))
-> Lexeme c a -> t (Lexeme c' a)
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f Lexeme c a
l
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
_ Lexeme c a
Discard = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall (category :: LexemeType -> *). Lexeme category 'Replacement
Discard
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f (Backreference Int
i c a
c) = forall (category :: LexemeType -> *) (a :: LexemeType).
Int -> category a -> Lexeme category a
Backreference Int
i forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (x :: LexemeType). c x -> t (c' x)
f c a
c
mapCategoryA forall (x :: LexemeType). c x -> t (c' x)
f (Multiple c 'Replacement
c) = forall (category :: LexemeType -> *).
category 'Replacement -> Lexeme category 'Replacement
Multiple forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (x :: LexemeType). c x -> t (c' x)
f c 'Replacement
c

-- | The type of a category after expansion.
newtype Expanded a = FromElements { forall (a :: LexemeType).
Expanded a -> [Either Grapheme [Lexeme Expanded a]]
elements :: [Either Grapheme [Lexeme Expanded a]] }
    deriving (Expanded a -> Expanded a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
/= :: Expanded a -> Expanded a -> Bool
$c/= :: forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
== :: Expanded a -> Expanded a -> Bool
$c== :: forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
Eq, Expanded a -> Expanded a -> Bool
Expanded a -> Expanded a -> Ordering
Expanded a -> Expanded a -> Expanded 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 (x :: LexemeType). Eq (Expanded x)
forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
forall (a :: LexemeType). Expanded a -> Expanded a -> Ordering
forall (a :: LexemeType). Expanded a -> Expanded a -> Expanded a
min :: Expanded a -> Expanded a -> Expanded a
$cmin :: forall (a :: LexemeType). Expanded a -> Expanded a -> Expanded a
max :: Expanded a -> Expanded a -> Expanded a
$cmax :: forall (a :: LexemeType). Expanded a -> Expanded a -> Expanded a
>= :: Expanded a -> Expanded a -> Bool
$c>= :: forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
> :: Expanded a -> Expanded a -> Bool
$c> :: forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
<= :: Expanded a -> Expanded a -> Bool
$c<= :: forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
< :: Expanded a -> Expanded a -> Bool
$c< :: forall (a :: LexemeType). Expanded a -> Expanded a -> Bool
compare :: Expanded a -> Expanded a -> Ordering
$ccompare :: forall (a :: LexemeType). Expanded a -> Expanded a -> Ordering
Ord, Int -> Expanded a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (a :: LexemeType). Int -> Expanded a -> ShowS
forall (a :: LexemeType). [Expanded a] -> ShowS
forall (a :: LexemeType). Expanded a -> String
showList :: [Expanded a] -> ShowS
$cshowList :: forall (a :: LexemeType). [Expanded a] -> ShowS
show :: Expanded a -> String
$cshow :: forall (a :: LexemeType). Expanded a -> String
showsPrec :: Int -> Expanded a -> ShowS
$cshowsPrec :: forall (a :: LexemeType). Int -> Expanded a -> ShowS
Show, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (a :: LexemeType) x. Rep (Expanded a) x -> Expanded a
forall (a :: LexemeType) x. Expanded a -> Rep (Expanded a) x
$cto :: forall (a :: LexemeType) x. Rep (Expanded a) x -> Expanded a
$cfrom :: forall (a :: LexemeType) x. Expanded a -> Rep (Expanded a) x
Generic, forall a. (a -> ()) -> NFData a
forall (a :: LexemeType). Expanded a -> ()
rnf :: Expanded a -> ()
$crnf :: forall (a :: LexemeType). Expanded a -> ()
NFData)

instance Semigroup (Expanded a) where
    (FromElements [Either Grapheme [Lexeme Expanded a]]
es) <> :: Expanded a -> Expanded a -> Expanded a
<> (FromElements [Either Grapheme [Lexeme Expanded a]]
es') = forall (a :: LexemeType).
[Either Grapheme [Lexeme Expanded a]] -> Expanded a
FromElements ([Either Grapheme [Lexeme Expanded a]]
es forall a. Semigroup a => a -> a -> a
<> [Either Grapheme [Lexeme Expanded a]]
es')

instance Monoid (Expanded a) where
    mempty :: Expanded a
mempty = forall (a :: LexemeType).
[Either Grapheme [Lexeme Expanded a]] -> Expanded a
FromElements []

generalise :: (c 'AnyPart -> c a) -> Lexeme c 'AnyPart -> Lexeme c a
generalise :: forall (c :: LexemeType -> *) (a :: LexemeType).
(c 'AnyPart -> c a) -> Lexeme c 'AnyPart -> Lexeme c a
generalise c 'AnyPart -> c a
_ (Grapheme Grapheme
g) = forall (category :: LexemeType -> *) (a :: LexemeType).
Grapheme -> Lexeme category a
Grapheme Grapheme
g
generalise c 'AnyPart -> c a
f (Category c 'AnyPart
es) = forall (category :: LexemeType -> *) (a :: LexemeType).
category a -> Lexeme category a
Category forall a b. (a -> b) -> a -> b
$ c 'AnyPart -> c a
f c 'AnyPart
es
generalise c 'AnyPart -> c a
f (Optional [Lexeme c 'AnyPart]
ls) = forall (category :: LexemeType -> *) (a :: LexemeType).
[Lexeme category a] -> Lexeme category a
Optional forall a b. (a -> b) -> a -> b
$ forall (c :: LexemeType -> *) (a :: LexemeType).
(c 'AnyPart -> c a) -> Lexeme c 'AnyPart -> Lexeme c a
generalise c 'AnyPart -> c a
f forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Lexeme c 'AnyPart]
ls
generalise c 'AnyPart -> c a
_ Lexeme c 'AnyPart
Geminate = forall (category :: LexemeType -> *) (a :: LexemeType).
Lexeme category a
Geminate
generalise c 'AnyPart -> c a
f (Backreference Int
i c 'AnyPart
es) = forall (category :: LexemeType -> *) (a :: LexemeType).
Int -> category a -> Lexeme category a
Backreference Int
i forall a b. (a -> b) -> a -> b
$ c 'AnyPart -> c a
f c 'AnyPart
es

generaliseExpanded :: Expanded 'AnyPart -> Expanded a
generaliseExpanded :: forall (a :: LexemeType). Expanded 'AnyPart -> Expanded a
generaliseExpanded = forall (a :: LexemeType).
[Either Grapheme [Lexeme Expanded a]] -> Expanded a
FromElements forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmapforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmapforall b c a. (b -> c) -> (a -> b) -> a -> c
.forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) (forall (c :: LexemeType -> *) (a :: LexemeType).
(c 'AnyPart -> c a) -> Lexeme c 'AnyPart -> Lexeme c a
generalise forall (a :: LexemeType). Expanded 'AnyPart -> Expanded a
generaliseExpanded) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (a :: LexemeType).
Expanded a -> [Either Grapheme [Lexeme Expanded a]]
elements

-- | A 'Lexeme' matching a single word boundary, specified as @#@ in Brassica syntax.
pattern Boundary :: Lexeme c a
pattern $bBoundary :: forall (category :: LexemeType -> *) (a :: LexemeType).
Lexeme category a
$mBoundary :: forall {r} {c :: LexemeType -> *} {a :: LexemeType}.
Lexeme c a -> ((# #) -> r) -> ((# #) -> r) -> r
Boundary = Grapheme GBoundary

deriving instance (forall x. Show (c x)) => Show (Lexeme c a)
deriving instance (forall x. Eq (c x)) => Eq (Lexeme c a)
deriving instance (forall x. Ord (c x)) => Ord (Lexeme c a)

instance (forall x. NFData (c x)) => NFData (Lexeme c a) where
    rnf :: Lexeme c a -> ()
rnf (Grapheme Grapheme
g) = forall a. NFData a => a -> ()
rnf Grapheme
g
    rnf (Category c a
cs) = forall a. NFData a => a -> ()
rnf c a
cs
    rnf (Optional [Lexeme c a]
ls) = forall a. NFData a => a -> ()
rnf [Lexeme c a]
ls
    rnf Lexeme c a
Metathesis = ()
    rnf Lexeme c a
Geminate = ()
    rnf (Wildcard Lexeme c a
l) = forall a. NFData a => a -> ()
rnf Lexeme c a
l
    rnf (Kleene Lexeme c a
l) = forall a. NFData a => a -> ()
rnf Lexeme c a
l
    rnf Lexeme c a
Discard = ()
    rnf (Backreference Int
i c a
l) = seq :: forall a b. a -> b -> b
seq Int
i forall a b. (a -> b) -> a -> b
$ forall a. NFData a => a -> ()
rnf c a
l
    rnf (Multiple c 'Replacement
l) = forall a. NFData a => a -> ()
rnf c 'Replacement
l

-- | An 'Environment' is a tuple of @(before, after)@ components,
-- corresponding to a ‘/ before _ after’ component of a sound change.
--
-- Note that an empty environment is just @([], [])@.
type Environment c = ([Lexeme c 'Env], [Lexeme c 'Env])

-- | Specifies application direction of rule — either left-to-right or right-to-left.
data Direction = LTR | RTL
    deriving (Direction -> Direction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Direction -> Direction -> Bool
$c/= :: Direction -> Direction -> Bool
== :: Direction -> Direction -> Bool
$c== :: Direction -> Direction -> Bool
Eq, Int -> Direction -> ShowS
[Direction] -> ShowS
Direction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Direction] -> ShowS
$cshowList :: [Direction] -> ShowS
show :: Direction -> String
$cshow :: Direction -> String
showsPrec :: Int -> Direction -> ShowS
$cshowsPrec :: Int -> Direction -> ShowS
Show, forall x. Rep Direction x -> Direction
forall x. Direction -> Rep Direction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Direction x -> Direction
$cfrom :: forall x. Direction -> Rep Direction x
Generic, Direction -> ()
forall a. (a -> ()) -> NFData a
rnf :: Direction -> ()
$crnf :: Direction -> ()
NFData)

-- | Flags which can be enabled, disabled or altered on a 'Rule' to
-- change how it is applied.
data Flags = Flags
  { Flags -> Bool
highlightChanges :: Bool
  , Flags -> Direction
applyDirection   :: Direction
  , Flags -> Bool
applyOnceOnly    :: Bool
  , Flags -> Bool
sporadic         :: Bool
  } deriving (Int -> Flags -> ShowS
[Flags] -> ShowS
Flags -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Flags] -> ShowS
$cshowList :: [Flags] -> ShowS
show :: Flags -> String
$cshow :: Flags -> String
showsPrec :: Int -> Flags -> ShowS
$cshowsPrec :: Int -> Flags -> ShowS
Show, forall x. Rep Flags x -> Flags
forall x. Flags -> Rep Flags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Flags x -> Flags
$cfrom :: forall x. Flags -> Rep Flags x
Generic, Flags -> ()
forall a. (a -> ()) -> NFData a
rnf :: Flags -> ()
$crnf :: Flags -> ()
NFData)

-- | A default selection of flags which are appropriate for most
-- rules:
--
-- @
-- 'defFlags' = 'Flags'
--     { 'highlightChanges' = 'True'
--     , 'applyDirection' = 'LTR'
--     , 'applyOnceOnly' = 'False'
--     , 'sporadic' = 'False'
--     }
-- @
--
-- That is: highlight changes, apply from left to right, apply
-- repeatedly, and don’t apply sporadically.
defFlags :: Flags
defFlags :: Flags
defFlags = Flags
    { highlightChanges :: Bool
highlightChanges = Bool
True
    , applyDirection :: Direction
applyDirection = Direction
LTR
    , applyOnceOnly :: Bool
applyOnceOnly = Bool
False
    , sporadic :: Bool
sporadic = Bool
False
    }

-- | A single sound change rule: in Brassica sound-change syntax with all elements specified,
-- @-flags target / replacement \/ environment1 | environment2 | … \/ exception@.
-- (And usually the 'plaintext' of the rule will contain a 'String' resembling that pattern.)
data Rule c = Rule
  { forall (c :: LexemeType -> *). Rule c -> [Lexeme c 'Target]
target      :: [Lexeme c 'Target]
  , forall (c :: LexemeType -> *). Rule c -> [Lexeme c 'Replacement]
replacement :: [Lexeme c 'Replacement]
  , forall (c :: LexemeType -> *). Rule c -> [Environment c]
environment :: [Environment c]
  , forall (c :: LexemeType -> *). Rule c -> Maybe (Environment c)
exception   :: Maybe (Environment c)
  , forall (c :: LexemeType -> *). Rule c -> Flags
flags       :: Flags
  , forall (c :: LexemeType -> *). Rule c -> String
plaintext   :: String
  } deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (c :: LexemeType -> *) x. Rep (Rule c) x -> Rule c
forall (c :: LexemeType -> *) x. Rule c -> Rep (Rule c) x
$cto :: forall (c :: LexemeType -> *) x. Rep (Rule c) x -> Rule c
$cfrom :: forall (c :: LexemeType -> *) x. Rule c -> Rep (Rule c) x
Generic)

deriving instance (forall a. Show (c a)) => Show (Rule c)
deriving instance (forall a. NFData (c a)) => NFData (Rule c)

-- | A 'Statement' can be either a single sound change rule, or a
-- directive (e.g. category definition).
data Statement c decl = RuleS (Rule c) | DirectiveS decl
    deriving (forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (c :: LexemeType -> *) decl x.
Rep (Statement c decl) x -> Statement c decl
forall (c :: LexemeType -> *) decl x.
Statement c decl -> Rep (Statement c decl) x
$cto :: forall (c :: LexemeType -> *) decl x.
Rep (Statement c decl) x -> Statement c decl
$cfrom :: forall (c :: LexemeType -> *) decl x.
Statement c decl -> Rep (Statement c decl) x
Generic)

deriving instance (forall a. Show (c a), Show decl) => Show (Statement c decl)
deriving instance (forall a. NFData (c a), NFData decl) => NFData (Statement c decl)

-- | A simple wrapper around 'plaintext' for 'Statement's. Returns
-- @"<directive>"@ for all 'DirectiveS' inputs.
plaintext' :: Statement c decl -> String
plaintext' :: forall (c :: LexemeType -> *) decl. Statement c decl -> String
plaintext' (RuleS Rule c
r) = forall (c :: LexemeType -> *). Rule c -> String
plaintext Rule c
r
plaintext' (DirectiveS decl
_) = String
"<directive>"

-- | A set of 'SoundChanges' is simply a list of 'Statement's.
type SoundChanges c decl = [Statement c decl]

-- | The individual operations used to construct a category in
-- Brassica sound-change syntax.
data CategoryModification = Union | Intersect | Subtract
    deriving (Int -> CategoryModification -> ShowS
[CategoryModification] -> ShowS
CategoryModification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CategoryModification] -> ShowS
$cshowList :: [CategoryModification] -> ShowS
show :: CategoryModification -> String
$cshow :: CategoryModification -> String
showsPrec :: Int -> CategoryModification -> ShowS
$cshowsPrec :: Int -> CategoryModification -> ShowS
Show, CategoryModification -> CategoryModification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CategoryModification -> CategoryModification -> Bool
$c/= :: CategoryModification -> CategoryModification -> Bool
== :: CategoryModification -> CategoryModification -> Bool
$c== :: CategoryModification -> CategoryModification -> Bool
Eq, Eq CategoryModification
CategoryModification -> CategoryModification -> Bool
CategoryModification -> CategoryModification -> Ordering
CategoryModification
-> CategoryModification -> CategoryModification
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
min :: CategoryModification
-> CategoryModification -> CategoryModification
$cmin :: CategoryModification
-> CategoryModification -> CategoryModification
max :: CategoryModification
-> CategoryModification -> CategoryModification
$cmax :: CategoryModification
-> CategoryModification -> CategoryModification
>= :: CategoryModification -> CategoryModification -> Bool
$c>= :: CategoryModification -> CategoryModification -> Bool
> :: CategoryModification -> CategoryModification -> Bool
$c> :: CategoryModification -> CategoryModification -> Bool
<= :: CategoryModification -> CategoryModification -> Bool
$c<= :: CategoryModification -> CategoryModification -> Bool
< :: CategoryModification -> CategoryModification -> Bool
$c< :: CategoryModification -> CategoryModification -> Bool
compare :: CategoryModification -> CategoryModification -> Ordering
$ccompare :: CategoryModification -> CategoryModification -> Ordering
Ord, forall x. Rep CategoryModification x -> CategoryModification
forall x. CategoryModification -> Rep CategoryModification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CategoryModification x -> CategoryModification
$cfrom :: forall x. CategoryModification -> Rep CategoryModification x
Generic, CategoryModification -> ()
forall a. (a -> ()) -> NFData a
rnf :: CategoryModification -> ()
$crnf :: CategoryModification -> ()
NFData)

-- | The specification of a category in Brassica sound-change syntax.
data CategorySpec a
    = CategorySpec [(CategoryModification, Either Grapheme [Lexeme CategorySpec a])]
    | MustInline String  -- ^ A single grapheme assumed to have been specified earlier as a category
    deriving (Int -> CategorySpec a -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (a :: LexemeType). Int -> CategorySpec a -> ShowS
forall (a :: LexemeType). [CategorySpec a] -> ShowS
forall (a :: LexemeType). CategorySpec a -> String
showList :: [CategorySpec a] -> ShowS
$cshowList :: forall (a :: LexemeType). [CategorySpec a] -> ShowS
show :: CategorySpec a -> String
$cshow :: forall (a :: LexemeType). CategorySpec a -> String
showsPrec :: Int -> CategorySpec a -> ShowS
$cshowsPrec :: forall (a :: LexemeType). Int -> CategorySpec a -> ShowS
Show, CategorySpec a -> CategorySpec a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
/= :: CategorySpec a -> CategorySpec a -> Bool
$c/= :: forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
== :: CategorySpec a -> CategorySpec a -> Bool
$c== :: forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
Eq, CategorySpec a -> CategorySpec a -> Bool
CategorySpec a -> CategorySpec a -> Ordering
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 (x :: LexemeType). Eq (CategorySpec x)
forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
forall (a :: LexemeType).
CategorySpec a -> CategorySpec a -> Ordering
forall (a :: LexemeType).
CategorySpec a -> CategorySpec a -> CategorySpec a
min :: CategorySpec a -> CategorySpec a -> CategorySpec a
$cmin :: forall (a :: LexemeType).
CategorySpec a -> CategorySpec a -> CategorySpec a
max :: CategorySpec a -> CategorySpec a -> CategorySpec a
$cmax :: forall (a :: LexemeType).
CategorySpec a -> CategorySpec a -> CategorySpec a
>= :: CategorySpec a -> CategorySpec a -> Bool
$c>= :: forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
> :: CategorySpec a -> CategorySpec a -> Bool
$c> :: forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
<= :: CategorySpec a -> CategorySpec a -> Bool
$c<= :: forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
< :: CategorySpec a -> CategorySpec a -> Bool
$c< :: forall (a :: LexemeType). CategorySpec a -> CategorySpec a -> Bool
compare :: CategorySpec a -> CategorySpec a -> Ordering
$ccompare :: forall (a :: LexemeType).
CategorySpec a -> CategorySpec a -> Ordering
Ord, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (a :: LexemeType) x.
Rep (CategorySpec a) x -> CategorySpec a
forall (a :: LexemeType) x.
CategorySpec a -> Rep (CategorySpec a) x
$cto :: forall (a :: LexemeType) x.
Rep (CategorySpec a) x -> CategorySpec a
$cfrom :: forall (a :: LexemeType) x.
CategorySpec a -> Rep (CategorySpec a) x
Generic, forall a. (a -> ()) -> NFData a
forall (a :: LexemeType). CategorySpec a -> ()
rnf :: CategorySpec a -> ()
$crnf :: forall (a :: LexemeType). CategorySpec a -> ()
NFData)

-- | The specification of a suprasegmental feature in Brassica
-- sound-change syntax.
data FeatureSpec = FeatureSpec
    { FeatureSpec -> Maybe String
featureBaseName :: Maybe String
    , FeatureSpec -> CategorySpec 'AnyPart
featureBaseValues :: CategorySpec 'AnyPart
    , FeatureSpec -> [(String, CategorySpec 'AnyPart)]
featureDerived :: [(String, CategorySpec 'AnyPart)]
    }
    deriving (Int -> FeatureSpec -> ShowS
[FeatureSpec] -> ShowS
FeatureSpec -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FeatureSpec] -> ShowS
$cshowList :: [FeatureSpec] -> ShowS
show :: FeatureSpec -> String
$cshow :: FeatureSpec -> String
showsPrec :: Int -> FeatureSpec -> ShowS
$cshowsPrec :: Int -> FeatureSpec -> ShowS
Show, FeatureSpec -> FeatureSpec -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FeatureSpec -> FeatureSpec -> Bool
$c/= :: FeatureSpec -> FeatureSpec -> Bool
== :: FeatureSpec -> FeatureSpec -> Bool
$c== :: FeatureSpec -> FeatureSpec -> Bool
Eq, Eq FeatureSpec
FeatureSpec -> FeatureSpec -> Bool
FeatureSpec -> FeatureSpec -> Ordering
FeatureSpec -> FeatureSpec -> FeatureSpec
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
min :: FeatureSpec -> FeatureSpec -> FeatureSpec
$cmin :: FeatureSpec -> FeatureSpec -> FeatureSpec
max :: FeatureSpec -> FeatureSpec -> FeatureSpec
$cmax :: FeatureSpec -> FeatureSpec -> FeatureSpec
>= :: FeatureSpec -> FeatureSpec -> Bool
$c>= :: FeatureSpec -> FeatureSpec -> Bool
> :: FeatureSpec -> FeatureSpec -> Bool
$c> :: FeatureSpec -> FeatureSpec -> Bool
<= :: FeatureSpec -> FeatureSpec -> Bool
$c<= :: FeatureSpec -> FeatureSpec -> Bool
< :: FeatureSpec -> FeatureSpec -> Bool
$c< :: FeatureSpec -> FeatureSpec -> Bool
compare :: FeatureSpec -> FeatureSpec -> Ordering
$ccompare :: FeatureSpec -> FeatureSpec -> Ordering
Ord, forall x. Rep FeatureSpec x -> FeatureSpec
forall x. FeatureSpec -> Rep FeatureSpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FeatureSpec x -> FeatureSpec
$cfrom :: forall x. FeatureSpec -> Rep FeatureSpec x
Generic, FeatureSpec -> ()
forall a. (a -> ()) -> NFData a
rnf :: FeatureSpec -> ()
$crnf :: FeatureSpec -> ()
NFData)

-- | A definition of a new category, either directly or via features.
data CategoryDefinition
    = DefineCategory String (CategorySpec 'AnyPart)
    | DefineFeature FeatureSpec
    deriving (Int -> CategoryDefinition -> ShowS
[CategoryDefinition] -> ShowS
CategoryDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CategoryDefinition] -> ShowS
$cshowList :: [CategoryDefinition] -> ShowS
show :: CategoryDefinition -> String
$cshow :: CategoryDefinition -> String
showsPrec :: Int -> CategoryDefinition -> ShowS
$cshowsPrec :: Int -> CategoryDefinition -> ShowS
Show, CategoryDefinition -> CategoryDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CategoryDefinition -> CategoryDefinition -> Bool
$c/= :: CategoryDefinition -> CategoryDefinition -> Bool
== :: CategoryDefinition -> CategoryDefinition -> Bool
$c== :: CategoryDefinition -> CategoryDefinition -> Bool
Eq, Eq CategoryDefinition
CategoryDefinition -> CategoryDefinition -> Bool
CategoryDefinition -> CategoryDefinition -> Ordering
CategoryDefinition -> CategoryDefinition -> CategoryDefinition
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
min :: CategoryDefinition -> CategoryDefinition -> CategoryDefinition
$cmin :: CategoryDefinition -> CategoryDefinition -> CategoryDefinition
max :: CategoryDefinition -> CategoryDefinition -> CategoryDefinition
$cmax :: CategoryDefinition -> CategoryDefinition -> CategoryDefinition
>= :: CategoryDefinition -> CategoryDefinition -> Bool
$c>= :: CategoryDefinition -> CategoryDefinition -> Bool
> :: CategoryDefinition -> CategoryDefinition -> Bool
$c> :: CategoryDefinition -> CategoryDefinition -> Bool
<= :: CategoryDefinition -> CategoryDefinition -> Bool
$c<= :: CategoryDefinition -> CategoryDefinition -> Bool
< :: CategoryDefinition -> CategoryDefinition -> Bool
$c< :: CategoryDefinition -> CategoryDefinition -> Bool
compare :: CategoryDefinition -> CategoryDefinition -> Ordering
$ccompare :: CategoryDefinition -> CategoryDefinition -> Ordering
Ord, forall x. Rep CategoryDefinition x -> CategoryDefinition
forall x. CategoryDefinition -> Rep CategoryDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CategoryDefinition x -> CategoryDefinition
$cfrom :: forall x. CategoryDefinition -> Rep CategoryDefinition x
Generic, CategoryDefinition -> ()
forall a. (a -> ()) -> NFData a
rnf :: CategoryDefinition -> ()
$crnf :: CategoryDefinition -> ()
NFData)

-- | A directive used in Brassica sound-change syntax: currently only
-- @categories … end@ or @new categories … end@
data Directive = Categories Bool [CategoryDefinition]
    deriving (Int -> Directive -> ShowS
[Directive] -> ShowS
Directive -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Directive] -> ShowS
$cshowList :: [Directive] -> ShowS
show :: Directive -> String
$cshow :: Directive -> String
showsPrec :: Int -> Directive -> ShowS
$cshowsPrec :: Int -> Directive -> ShowS
Show, Directive -> Directive -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Directive -> Directive -> Bool
$c/= :: Directive -> Directive -> Bool
== :: Directive -> Directive -> Bool
$c== :: Directive -> Directive -> Bool
Eq, Eq Directive
Directive -> Directive -> Bool
Directive -> Directive -> Ordering
Directive -> Directive -> Directive
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
min :: Directive -> Directive -> Directive
$cmin :: Directive -> Directive -> Directive
max :: Directive -> Directive -> Directive
$cmax :: Directive -> Directive -> Directive
>= :: Directive -> Directive -> Bool
$c>= :: Directive -> Directive -> Bool
> :: Directive -> Directive -> Bool
$c> :: Directive -> Directive -> Bool
<= :: Directive -> Directive -> Bool
$c<= :: Directive -> Directive -> Bool
< :: Directive -> Directive -> Bool
$c< :: Directive -> Directive -> Bool
compare :: Directive -> Directive -> Ordering
$ccompare :: Directive -> Directive -> Ordering
Ord, forall x. Rep Directive x -> Directive
forall x. Directive -> Rep Directive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Directive x -> Directive
$cfrom :: forall x. Directive -> Rep Directive x
Generic, Directive -> ()
forall a. (a -> ()) -> NFData a
rnf :: Directive -> ()
$crnf :: Directive -> ()
NFData)