Skip to content

Commit

Permalink
Interpretation (#298): remove "special vals"
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyYakeley committed Oct 15, 2024
1 parent ab64dfb commit 21cbd29
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 27 deletions.
1 change: 0 additions & 1 deletion Pinafore/pinafore-language/lib/Pinafore/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Pinafore.Language
, LibraryContext(..)
, mkLibraryContext
, pinaforeLibrary
, QSpecialVals(..)
, QError
, fromParseResult
, InterpretResult
Expand Down
10 changes: 1 addition & 9 deletions Pinafore/pinafore-language/lib/Pinafore/Language/Interpret.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,8 @@ parseToValueSubsume t text = do
val <- parseToValue text []
tsSubsumeValue @QTypeSystem t val

spvals :: (?library :: LibraryContext) => QSpecialVals
spvals = let
specialEvaluate :: forall t. QType 'Positive t -> Text -> IO (Result QError t)
specialEvaluate t text = do
ier <- evaluate $ runPinaforeScoped "<evaluate>" $ parseToValueSubsume t text
runInterpretResult ier
in MkQSpecialVals {..}

runPinaforeScoped :: (?library :: LibraryContext) => String -> QInterpreter a -> InterpretResult a
runPinaforeScoped sourcename ma =
runInterpreter (initialPos sourcename) ?library spvals $ do
runInterpreter (initialPos sourcename) ?library $ do
sd <- interpretImportDeclaration builtInModuleName
withScopeDocs sd ma
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Pinafore.Language.Interpreter.Binding
( QSpecialVals(..)
, QSignature(..)
( QSignature(..)
, QRecordValue(..)
, QRecordConstructor(..)
, recordConstructorToValue
Expand All @@ -21,11 +20,6 @@ import Pinafore.Language.Type.Family
import Pinafore.Language.Type.Ground
import Pinafore.Language.Type.Subtype ()

newtype QSpecialVals = MkQSpecialVals
{ specialEvaluate :: forall t. QType 'Positive t -> Text -> IO (Result QError t)
-- ^ in IO because this can do things like import files
}

data QSignature (polarity :: Polarity) (t :: Type) =
ValueSignature (Maybe SomeFamilialType)
Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module Pinafore.Language.Interpreter.Interpreter
, getRenderFullName
, getBindingInfoLookup
, getNamespaceWithScope
, getSpecialVals
, exportScope
, getModule
, getSubtypeScope
Expand Down Expand Up @@ -56,7 +55,6 @@ data InterpretContext = MkInterpretContext
, icVarIDState :: VarIDState
, icScope :: QScope
, icCurrentNamespace :: Namespace
, icSpecialVals :: QSpecialVals
, icModulePath :: [ModuleName]
, icLoadModule :: LoadModule
}
Expand Down Expand Up @@ -170,9 +168,6 @@ currentNamespaceParam :: Param QInterpreter Namespace
currentNamespaceParam =
lensMapParam (\bfb a -> fmap (\b -> a {icCurrentNamespace = b}) $ bfb $ icCurrentNamespace a) contextParam

specialValsParam :: Param QInterpreter QSpecialVals
specialValsParam = lensMapParam (\bfb a -> fmap (\b -> a {icSpecialVals = b}) $ bfb $ icSpecialVals a) contextParam

modulePathParam :: Param QInterpreter [ModuleName]
modulePathParam = lensMapParam (\bfb a -> fmap (\b -> a {icModulePath = b}) $ bfb $ icModulePath a) contextParam

Expand Down Expand Up @@ -203,8 +198,8 @@ data LibraryContext = MkLibraryContext
{ lcLoadModule :: LoadModule
}

runInterpreter :: SourcePos -> LibraryContext -> QSpecialVals -> QInterpreter a -> InterpretResult a
runInterpreter icSourcePos MkLibraryContext {..} icSpecialVals qa = let
runInterpreter :: SourcePos -> LibraryContext -> QInterpreter a -> InterpretResult a
runInterpreter icSourcePos MkLibraryContext {..} qa = let
icVarIDState = szero
icScope = emptyScope
icModulePath = []
Expand Down Expand Up @@ -340,6 +335,3 @@ newIdentifiedType =
Refl <- unsafeIdentifyKind @_ @(CCRVariancesKind dv) typeID
Refl <- unsafeIdentify @_ @gt typeID
return $ identifiedFamilialType typeID

getSpecialVals :: QInterpreter QSpecialVals
getSpecialVals = paramAsk specialValsParam

0 comments on commit 21cbd29

Please sign in to comment.