-- | Common data types

module Language.Giml.Common where

import Data.Data (Data)
import qualified Data.Text as T
import qualified Data.Map as M

-- | A type variable name
type TypeVar = T.Text
-- | A type constructor name
type TypeCon = T.Text
-- | A data constructor
type Constr = T.Text
-- | A record label
type Label = T.Text

-- | A general record data type
type Record a
  = M.Map Label a

-- | A general variant data type
data Variant a
  = Variant Constr a
  deriving (Int -> Variant a -> ShowS
[Variant a] -> ShowS
Variant a -> String
(Int -> Variant a -> ShowS)
-> (Variant a -> String)
-> ([Variant a] -> ShowS)
-> Show (Variant a)
forall a. Show a => Int -> Variant a -> ShowS
forall a. Show a => [Variant a] -> ShowS
forall a. Show a => Variant a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Variant a] -> ShowS
$cshowList :: forall a. Show a => [Variant a] -> ShowS
show :: Variant a -> String
$cshow :: forall a. Show a => Variant a -> String
showsPrec :: Int -> Variant a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Variant a -> ShowS
Show, Variant a -> Variant a -> Bool
(Variant a -> Variant a -> Bool)
-> (Variant a -> Variant a -> Bool) -> Eq (Variant a)
forall a. Eq a => Variant a -> Variant a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Variant a -> Variant a -> Bool
$c/= :: forall a. Eq a => Variant a -> Variant a -> Bool
== :: Variant a -> Variant a -> Bool
$c== :: forall a. Eq a => Variant a -> Variant a -> Bool
Eq, Eq (Variant a)
Eq (Variant a)
-> (Variant a -> Variant a -> Ordering)
-> (Variant a -> Variant a -> Bool)
-> (Variant a -> Variant a -> Bool)
-> (Variant a -> Variant a -> Bool)
-> (Variant a -> Variant a -> Bool)
-> (Variant a -> Variant a -> Variant a)
-> (Variant a -> Variant a -> Variant a)
-> Ord (Variant a)
Variant a -> Variant a -> Bool
Variant a -> Variant a -> Ordering
Variant a -> Variant a -> Variant 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 (Variant a)
forall a. Ord a => Variant a -> Variant a -> Bool
forall a. Ord a => Variant a -> Variant a -> Ordering
forall a. Ord a => Variant a -> Variant a -> Variant a
min :: Variant a -> Variant a -> Variant a
$cmin :: forall a. Ord a => Variant a -> Variant a -> Variant a
max :: Variant a -> Variant a -> Variant a
$cmax :: forall a. Ord a => Variant a -> Variant a -> Variant a
>= :: Variant a -> Variant a -> Bool
$c>= :: forall a. Ord a => Variant a -> Variant a -> Bool
> :: Variant a -> Variant a -> Bool
$c> :: forall a. Ord a => Variant a -> Variant a -> Bool
<= :: Variant a -> Variant a -> Bool
$c<= :: forall a. Ord a => Variant a -> Variant a -> Bool
< :: Variant a -> Variant a -> Bool
$c< :: forall a. Ord a => Variant a -> Variant a -> Bool
compare :: Variant a -> Variant a -> Ordering
$ccompare :: forall a. Ord a => Variant a -> Variant a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Variant a)
Ord, Typeable (Variant a)
DataType
Constr
Typeable (Variant a)
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Variant a -> c (Variant a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Variant a))
-> (Variant a -> Constr)
-> (Variant a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Variant a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Variant a)))
-> ((forall b. Data b => b -> b) -> Variant a -> Variant a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Variant a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Variant a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Variant a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Variant a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Variant a -> m (Variant a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variant a -> m (Variant a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Variant a -> m (Variant a))
-> Data (Variant a)
Variant a -> DataType
Variant a -> Constr
(forall d. Data d => c (t d)) -> Maybe (c (Variant a))
(forall b. Data b => b -> b) -> Variant a -> Variant a
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Variant a -> c (Variant a)
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Variant a)
forall a. Data a => Typeable (Variant a)
forall a. Data a => Variant a -> DataType
forall a. Data a => Variant a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Variant a -> Variant a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Variant a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Variant a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Variant a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Variant a -> c (Variant a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Variant a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Variant 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) -> Variant a -> u
forall u. (forall d. Data d => d -> u) -> Variant a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Variant a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Variant a -> c (Variant a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Variant a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Variant a))
$cVariant :: Constr
$tVariant :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
gmapMp :: (forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
gmapM :: (forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Variant a -> m (Variant a)
gmapQi :: Int -> (forall d. Data d => d -> u) -> Variant a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Variant a -> u
gmapQ :: (forall d. Data d => d -> u) -> Variant a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Variant a -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Variant a -> r
gmapT :: (forall b. Data b => b -> b) -> Variant a -> Variant a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Variant a -> Variant a
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Variant a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Variant a))
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c (Variant a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Variant a))
dataTypeOf :: Variant a -> DataType
$cdataTypeOf :: forall a. Data a => Variant a -> DataType
toConstr :: Variant a -> Constr
$ctoConstr :: forall a. Data a => Variant a -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Variant a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Variant a)
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Variant a -> c (Variant a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Variant a -> c (Variant a)
$cp1Data :: forall a. Data a => Typeable (Variant a)
Data, a -> Variant b -> Variant a
(a -> b) -> Variant a -> Variant b
(forall a b. (a -> b) -> Variant a -> Variant b)
-> (forall a b. a -> Variant b -> Variant a) -> Functor Variant
forall a b. a -> Variant b -> Variant a
forall a b. (a -> b) -> Variant a -> Variant b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Variant b -> Variant a
$c<$ :: forall a b. a -> Variant b -> Variant a
fmap :: (a -> b) -> Variant a -> Variant b
$cfmap :: forall a b. (a -> b) -> Variant a -> Variant b
Functor, Variant a -> Bool
(a -> m) -> Variant a -> m
(a -> b -> b) -> b -> Variant a -> b
(forall m. Monoid m => Variant m -> m)
-> (forall m a. Monoid m => (a -> m) -> Variant a -> m)
-> (forall m a. Monoid m => (a -> m) -> Variant a -> m)
-> (forall a b. (a -> b -> b) -> b -> Variant a -> b)
-> (forall a b. (a -> b -> b) -> b -> Variant a -> b)
-> (forall b a. (b -> a -> b) -> b -> Variant a -> b)
-> (forall b a. (b -> a -> b) -> b -> Variant a -> b)
-> (forall a. (a -> a -> a) -> Variant a -> a)
-> (forall a. (a -> a -> a) -> Variant a -> a)
-> (forall a. Variant a -> [a])
-> (forall a. Variant a -> Bool)
-> (forall a. Variant a -> Int)
-> (forall a. Eq a => a -> Variant a -> Bool)
-> (forall a. Ord a => Variant a -> a)
-> (forall a. Ord a => Variant a -> a)
-> (forall a. Num a => Variant a -> a)
-> (forall a. Num a => Variant a -> a)
-> Foldable Variant
forall a. Eq a => a -> Variant a -> Bool
forall a. Num a => Variant a -> a
forall a. Ord a => Variant a -> a
forall m. Monoid m => Variant m -> m
forall a. Variant a -> Bool
forall a. Variant a -> Int
forall a. Variant a -> [a]
forall a. (a -> a -> a) -> Variant a -> a
forall m a. Monoid m => (a -> m) -> Variant a -> m
forall b a. (b -> a -> b) -> b -> Variant a -> b
forall a b. (a -> b -> b) -> b -> Variant a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Variant a -> a
$cproduct :: forall a. Num a => Variant a -> a
sum :: Variant a -> a
$csum :: forall a. Num a => Variant a -> a
minimum :: Variant a -> a
$cminimum :: forall a. Ord a => Variant a -> a
maximum :: Variant a -> a
$cmaximum :: forall a. Ord a => Variant a -> a
elem :: a -> Variant a -> Bool
$celem :: forall a. Eq a => a -> Variant a -> Bool
length :: Variant a -> Int
$clength :: forall a. Variant a -> Int
null :: Variant a -> Bool
$cnull :: forall a. Variant a -> Bool
toList :: Variant a -> [a]
$ctoList :: forall a. Variant a -> [a]
foldl1 :: (a -> a -> a) -> Variant a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Variant a -> a
foldr1 :: (a -> a -> a) -> Variant a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Variant a -> a
foldl' :: (b -> a -> b) -> b -> Variant a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Variant a -> b
foldl :: (b -> a -> b) -> b -> Variant a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Variant a -> b
foldr' :: (a -> b -> b) -> b -> Variant a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Variant a -> b
foldr :: (a -> b -> b) -> b -> Variant a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Variant a -> b
foldMap' :: (a -> m) -> Variant a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Variant a -> m
foldMap :: (a -> m) -> Variant a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Variant a -> m
fold :: Variant m -> m
$cfold :: forall m. Monoid m => Variant m -> m
Foldable, Functor Variant
Foldable Variant
Functor Variant
-> Foldable Variant
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Variant a -> f (Variant b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Variant (f a) -> f (Variant a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Variant a -> m (Variant b))
-> (forall (m :: * -> *) a.
    Monad m =>
    Variant (m a) -> m (Variant a))
-> Traversable Variant
(a -> f b) -> Variant a -> f (Variant b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Variant (m a) -> m (Variant a)
forall (f :: * -> *) a.
Applicative f =>
Variant (f a) -> f (Variant a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Variant a -> m (Variant b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Variant a -> f (Variant b)
sequence :: Variant (m a) -> m (Variant a)
$csequence :: forall (m :: * -> *) a. Monad m => Variant (m a) -> m (Variant a)
mapM :: (a -> m b) -> Variant a -> m (Variant b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Variant a -> m (Variant b)
sequenceA :: Variant (f a) -> f (Variant a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Variant (f a) -> f (Variant a)
traverse :: (a -> f b) -> Variant a -> f (Variant b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Variant a -> f (Variant b)
$cp2Traversable :: Foldable Variant
$cp1Traversable :: Functor Variant
Traversable)