module SyntaxTrees.Purescript.Common where

import Data.List (intercalate)


newtype Var
  = Var String

newtype Ctor
  = Ctor String

newtype VarOp
  = VarOp String

newtype CtorOp
  = CtorOp String

newtype Class
  = Class String

newtype Module
  = Module [String]

data Literal
  = UnitLit
  | BoolLit Bool
  | IntLit String
  | NumberLit String
  | CharLit Char
  | StringLit String


data QVar
  = QVar (Maybe Module) Var

data QCtor
  = QCtor (Maybe Module) Ctor

data QVarOp
  = QVarOp (Maybe Module) VarOp

data QCtorOp
  = QCtorOp (Maybe Module) CtorOp

data QClass
  = QClass (Maybe Module) Class



instance Show Var where
  show :: Var -> String
show (Var String
x) = String
x

instance Show Ctor where
  show :: Ctor -> String
show (Ctor String
x) = String
x

instance Show VarOp where
  show :: VarOp -> String
show (VarOp String
x) = String
x

instance Show CtorOp where
  show :: CtorOp -> String
show (CtorOp String
x) = String
x

instance Show Class where
  show :: Class -> String
show (Class String
x) = String
x

instance Show Module where
  show :: Module -> String
show (Module [String]
x) = forall a. [a] -> [[a]] -> [a]
intercalate String
"." [String]
x

instance Show Literal where
  show :: Literal -> String
show Literal
UnitLit         = String
"unit"
  show (BoolLit Bool
True)  = String
"true"
  show (BoolLit Bool
False) = String
"false"
  show (IntLit String
x)      = String
x
  show (NumberLit String
x)   = String
x
  show (CharLit Char
x)     = forall a. Show a => a -> String
show Char
x
  show (StringLit String
x)   = forall a. Show a => a -> String
show String
x


instance Show QVar where
  show :: QVar -> String
show (QVar Maybe Module
x Var
y) = forall a b. (Show a, Show b) => Maybe a -> b -> String
showQualified Maybe Module
x Var
y

instance Show QCtor where
  show :: QCtor -> String
show (QCtor Maybe Module
x Ctor
y) = forall a b. (Show a, Show b) => Maybe a -> b -> String
showQualified Maybe Module
x Ctor
y

instance Show QVarOp where
  show :: QVarOp -> String
show (QVarOp Maybe Module
x VarOp
y) = forall a b. (Show a, Show b) => Maybe a -> b -> String
showQualified Maybe Module
x VarOp
y

instance Show QCtorOp where
  show :: QCtorOp -> String
show (QCtorOp Maybe Module
x CtorOp
y) = forall a b. (Show a, Show b) => Maybe a -> b -> String
showQualified Maybe Module
x CtorOp
y

instance Show QClass where
  show :: QClass -> String
show (QClass Maybe Module
x Class
y) = forall a b. (Show a, Show b) => Maybe a -> b -> String
showQualified Maybe Module
x Class
y


showQualified :: (Show a, Show b) => Maybe a -> b -> String
showQualified :: forall a b. (Show a, Show b) => Maybe a -> b -> String
showQualified Maybe a
x b
y = forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ((forall a. [a] -> [a] -> [a]
++ String
".") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show) Maybe a
x forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show b
y