{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE StandaloneDeriving #-}
module HsExtension where
import GhcPrelude
import GHC.Exts (Constraint)
import Data.Data hiding ( Fixity )
import PlaceHolder
import BasicTypes
import ConLike
import NameSet
import Name
import RdrName
import Var
import Type ( Type )
import Outputable
import SrcLoc (Located)
import Coercion
import TcEvidence
data GhcPass (c :: Pass)
deriving instance Eq (GhcPass c)
deriving instance Typeable c => Data (GhcPass c)
data Pass = Parsed | Renamed | Typechecked
deriving (Data)
type GhcPs = GhcPass 'Parsed
type GhcRn = GhcPass 'Renamed
type GhcTc = GhcPass 'Typechecked
type GhcTcId = GhcTc
type family PostTc x ty
type instance PostTc GhcPs ty = PlaceHolder
type instance PostTc GhcRn ty = PlaceHolder
type instance PostTc GhcTc ty = ty
type family PostRn x ty
type instance PostRn GhcPs ty = PlaceHolder
type instance PostRn GhcRn ty = ty
type instance PostRn GhcTc ty = ty
type family IdP p
type instance IdP GhcPs = RdrName
type instance IdP GhcRn = Name
type instance IdP GhcTc = Id
type family XHsChar x
type family XHsCharPrim x
type family XHsString x
type family XHsStringPrim x
type family XHsInt x
type family XHsIntPrim x
type family XHsWordPrim x
type family XHsInt64Prim x
type family XHsWord64Prim x
type family XHsInteger x
type family XHsRat x
type family XHsFloatPrim x
type family XHsDoublePrim x
type ForallX (c :: * -> Constraint) (x :: *) =
( c (XHsChar x)
, c (XHsCharPrim x)
, c (XHsString x)
, c (XHsStringPrim x)
, c (XHsInt x)
, c (XHsIntPrim x)
, c (XHsWordPrim x)
, c (XHsInt64Prim x)
, c (XHsWord64Prim x)
, c (XHsInteger x)
, c (XHsRat x)
, c (XHsFloatPrim x)
, c (XHsDoublePrim x)
)
type instance XHsChar GhcPs = SourceText
type instance XHsCharPrim GhcPs = SourceText
type instance XHsString GhcPs = SourceText
type instance XHsStringPrim GhcPs = SourceText
type instance XHsInt GhcPs = ()
type instance XHsIntPrim GhcPs = SourceText
type instance XHsWordPrim GhcPs = SourceText
type instance XHsInt64Prim GhcPs = SourceText
type instance XHsWord64Prim GhcPs = SourceText
type instance XHsInteger GhcPs = SourceText
type instance XHsRat GhcPs = ()
type instance XHsFloatPrim GhcPs = ()
type instance XHsDoublePrim GhcPs = ()
type instance XHsChar GhcRn = SourceText
type instance XHsCharPrim GhcRn = SourceText
type instance XHsString GhcRn = SourceText
type instance XHsStringPrim GhcRn = SourceText
type instance XHsInt GhcRn = ()
type instance XHsIntPrim GhcRn = SourceText
type instance XHsWordPrim GhcRn = SourceText
type instance XHsInt64Prim GhcRn = SourceText
type instance XHsWord64Prim GhcRn = SourceText
type instance XHsInteger GhcRn = SourceText
type instance XHsRat GhcRn = ()
type instance XHsFloatPrim GhcRn = ()
type instance XHsDoublePrim GhcRn = ()
type instance XHsChar GhcTc = SourceText
type instance XHsCharPrim GhcTc = SourceText
type instance XHsString GhcTc = SourceText
type instance XHsStringPrim GhcTc = SourceText
type instance XHsInt GhcTc = ()
type instance XHsIntPrim GhcTc = SourceText
type instance XHsWordPrim GhcTc = SourceText
type instance XHsInt64Prim GhcTc = SourceText
type instance XHsWord64Prim GhcTc = SourceText
type instance XHsInteger GhcTc = SourceText
type instance XHsRat GhcTc = ()
type instance XHsFloatPrim GhcTc = ()
type instance XHsDoublePrim GhcTc = ()
class HasSourceText a where
noSourceText :: a
sourceText :: String -> a
setSourceText :: SourceText -> a
getSourceText :: a -> SourceText
type SourceTextX x =
( HasSourceText (XHsChar x)
, HasSourceText (XHsCharPrim x)
, HasSourceText (XHsString x)
, HasSourceText (XHsStringPrim x)
, HasSourceText (XHsIntPrim x)
, HasSourceText (XHsWordPrim x)
, HasSourceText (XHsInt64Prim x)
, HasSourceText (XHsWord64Prim x)
, HasSourceText (XHsInteger x)
)
instance HasSourceText SourceText where
noSourceText = NoSourceText
sourceText s = SourceText s
setSourceText s = s
getSourceText a = a
class HasDefault a where
def :: a
instance HasDefault () where
def = ()
instance HasDefault SourceText where
def = NoSourceText
type HasDefaultX x = ForallX HasDefault x
class Convertable a b | a -> b where
convert :: a -> b
instance Convertable a a where
convert = id
type ConvertIdX a b =
(XHsDoublePrim a ~ XHsDoublePrim b,
XHsFloatPrim a ~ XHsFloatPrim b,
XHsRat a ~ XHsRat b,
XHsInteger a ~ XHsInteger b,
XHsWord64Prim a ~ XHsWord64Prim b,
XHsInt64Prim a ~ XHsInt64Prim b,
XHsWordPrim a ~ XHsWordPrim b,
XHsIntPrim a ~ XHsIntPrim b,
XHsInt a ~ XHsInt b,
XHsStringPrim a ~ XHsStringPrim b,
XHsString a ~ XHsString b,
XHsCharPrim a ~ XHsCharPrim b,
XHsChar a ~ XHsChar b)
type DataId p =
( Data p
, ForallX Data p
, Data (NameOrRdrName (IdP p))
, Data (IdP p)
, Data (PostRn p (IdP p))
, Data (PostRn p (Located Name))
, Data (PostRn p Bool)
, Data (PostRn p Fixity)
, Data (PostRn p NameSet)
, Data (PostRn p [Name])
, Data (PostTc p (IdP p))
, Data (PostTc p Coercion)
, Data (PostTc p ConLike)
, Data (PostTc p HsWrapper)
, Data (PostTc p Type)
, Data (PostTc p [ConLike])
, Data (PostTc p [Type])
)
type OutputableBndrId id =
( OutputableBndr (NameOrRdrName (IdP id))
, OutputableBndr (IdP id)
)