Skip to content

Commit 2bafbae

Browse files
committed
Typecheck main in PSCi (purescript#2163)
1 parent 2ca82f8 commit 2bafbae

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Language/PureScript/Interactive/Module.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,27 @@ createTemporaryModule :: Bool -> PSCiState -> P.Expr -> P.Module
4545
createTemporaryModule exec PSCiState{psciImportedModules = imports, psciLetBindings = lets} val =
4646
let
4747
moduleName = P.ModuleName [P.ProperName "$PSCI"]
48+
effModuleName = P.moduleNameFromString "Control.Monad.Eff"
49+
effImport = (effModuleName, P.Implicit, Just (P.ModuleName [P.ProperName "$Eff"]))
4850
supportImport = (supportModuleName, P.Implicit, Just (P.ModuleName [P.ProperName "$Support"]))
4951
eval = P.Var (P.Qualified (Just (P.ModuleName [P.ProperName "$Support"])) (P.Ident "eval"))
5052
mainValue = P.App eval (P.Var (P.Qualified Nothing (P.Ident "it")))
5153
itDecl = P.ValueDeclaration (P.Ident "it") P.Public [] $ Right val
54+
typeDecl = P.TypeDeclaration (P.Ident "$main")
55+
(P.TypeApp
56+
(P.TypeApp
57+
(P.TypeConstructor
58+
(P.Qualified (Just (P.ModuleName [P.ProperName "$Eff"])) (P.ProperName "Eff")))
59+
(P.TypeWildcard internalSpan))
60+
(P.TypeWildcard internalSpan))
5261
mainDecl = P.ValueDeclaration (P.Ident "$main") P.Public [] $ Right mainValue
53-
decls = if exec then [itDecl, mainDecl] else [itDecl]
62+
decls = if exec then [itDecl, typeDecl, mainDecl] else [itDecl]
63+
internalSpan = P.internalModuleSourceSpan "<internal>"
5464
in
55-
P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName ((importDecl `map` (supportImport : imports)) ++ lets ++ decls) Nothing
65+
P.Module internalSpan
66+
[] moduleName
67+
((importDecl `map` (effImport : supportImport : imports)) ++ lets ++ decls)
68+
Nothing
5669

5770

5871
-- |

0 commit comments

Comments
 (0)