module Data.Logic.Classes.Variable
( Variable(..)
, variants
, showVariable
) where
import Data.Data (Data)
import Data.Logic.Classes.Pretty (Pretty)
import qualified Data.Set as Set
import Data.String (IsString)
import Text.PrettyPrint (Doc)
class (Ord v, IsString v, Data v, Pretty v) => Variable v where
variant :: v -> Set.Set v -> v
prefix :: String -> v -> v
prettyVariable :: v -> Doc
variants :: Variable v => v -> [v]
variants v0 =
iter' Set.empty v0
where iter' s v = let v' = variant v s in v' : iter' (Set.insert v s) v'
showVariable :: Variable v => v -> String
showVariable v = "fromString (" ++ show (show (prettyVariable v)) ++ ")"