{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveGeneric #-}
module Language.PureScript.TypeClassDictionaries where
import Prelude.Compat
import GHC.Generics (Generic)
import Control.DeepSeq (NFData)
import Data.Monoid ((<>))
import Data.Text (Text, pack)
import Language.PureScript.Names
import Language.PureScript.Types
data TypeClassDictionaryInScope v
= TypeClassDictionaryInScope {
tcdChain :: [Qualified Ident]
, tcdIndex :: Integer
, tcdValue :: v
, tcdPath :: [(Qualified (ProperName 'ClassName), Integer)]
, tcdClassName :: Qualified (ProperName 'ClassName)
, tcdInstanceTypes :: [Type]
, tcdDependencies :: Maybe [Constraint]
}
deriving (Show, Functor, Foldable, Traversable, Generic)
instance NFData v => NFData (TypeClassDictionaryInScope v)
type NamedDict = TypeClassDictionaryInScope (Qualified Ident)
superclassName :: Qualified (ProperName 'ClassName) -> Integer -> Text
superclassName pn index = runProperName (disqualify pn) <> pack (show index)