{-# OPTIONS_HADDOCK hide #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell #-}
#ifdef ONLY_ONE_LANGUAGE
module Cubix.Language.Python.Parametric.Full.Names () where
#else
module Cubix.Language.Python.Parametric.Full.Names (
origASTTypes
, newASTTypes
, pythonSigNames
, makeSubsts
) where
import Data.Map ( Map )
import qualified Data.Map as Map
import Language.Haskell.TH hiding ( Name )
import qualified Language.Haskell.TH as TH
import Language.Python.Common.AST
import Data.Comp.Trans ( runCompTrans, generateNameLists, getTypeParamVars )
import Cubix.Language.Parametric.Syntax.Base
import Cubix.Language.Parametric.Syntax.Functor
runCompTrans $ generateNameLists ''Module
pythonSigNames :: [TH.Name]
pythonSigNames :: [Name]
pythonSigNames = [Name]
newASTTypes [Name] -> [Name] -> [Name]
forall a. [a] -> [a] -> [a]
++ [''PairF, ''ListF, ''MaybeF, ''UnitF, ''CharF]
makeSubsts :: Q (Map TH.Name Type)
makeSubsts :: Q (Map Name Type)
makeSubsts = do
[Name]
vars <- CompTrans [Name] -> Q [Name]
forall a. CompTrans a -> Q a
runCompTrans (CompTrans [Name] -> Q [Name]) -> CompTrans [Name] -> Q [Name]
forall a b. (a -> b) -> a -> b
$ [Name] -> CompTrans [Name]
getTypeParamVars [Name]
origASTTypes
let substs :: Map Name Type
substs = [(Name, Type)] -> Map Name Type
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([Name] -> [Type] -> [(Name, Type)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Name]
vars (Type -> [Type]
forall a. a -> [a]
repeat (Type -> [Type]) -> Type -> [Type]
forall a b. (a -> b) -> a -> b
$ Int -> Type
TupleT 0))
Map Name Type -> Q (Map Name Type)
forall (m :: * -> *) a. Monad m => a -> m a
return Map Name Type
substs
#endif