@@ -47,12 +47,12 @@ completion ms = completeWord Nothing " \t\n\r" findCompletions
47 findCompletions :: String -> IO [Completion]
47 findCompletions :: String -> IO [Completion]
48 findCompletions str = do
48 findCompletions str = do
49 files <- listFiles str
49 files <- listFiles str
50− let names = nub $ [ show qual
50+ let names = nub [ show qual
51− | P.Module moduleName ds <- ms
51+ | P.Module moduleName ds <- ms
52− , ident <- mapMaybe getDeclName ds
52+ , ident <- mapMaybe getDeclName ds
53− , qual <- [ P.Qualified Nothing ident
53+ , qual <- [ P.Qualified Nothing ident
54− , P.Qualified (Just (P.ModuleName moduleName)) ident]
54+ , P.Qualified (Just (P.ModuleName moduleName)) ident]
56 let matches = filter (isPrefixOf str) names
56 let matches = filter (isPrefixOf str) names
57 return $ map simpleCompletion matches ++ files
57 return $ map simpleCompletion matches ++ files
58 getDeclName :: P.Declaration -> Maybe P.Ident
58 getDeclName :: P.Declaration -> Maybe P.Ident
@@ -66,8 +66,9 @@ createTemporaryModule imports value =
66 importDecl m = P.ImportDeclaration m Nothing
66 importDecl m = P.ImportDeclaration m Nothing
67 traceModule = P.ModuleName (P.ProperName "Trace")
67 traceModule = P.ModuleName (P.ProperName "Trace")
68 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
68 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
69+ returnedValue = P.App (P.Var (P.Qualified Nothing (P.Ident "return"))) value
69 mainDecl = P.ValueDeclaration (P.Ident "main") [] Nothing
70 mainDecl = P.ValueDeclaration (P.Ident "main") [] Nothing
70− (P.Do [ P.DoNotationBind (P.VarBinder (P.Ident "it")) value
71+ (P.Do [ P.DoNotationBind (P.VarBinder (P.Ident "it")) returnedValue
71 , P.DoNotationValue (P.App trace (P.Var (P.Qualified Nothing (P.Ident "it"))) )
72 , P.DoNotationValue (P.App trace (P.Var (P.Qualified Nothing (P.Ident "it"))) )
@@ -140,8 +141,7 @@ main = do
140 case cmd of
141 case cmd of
141 Empty -> go imports loadedModules
142 Empty -> go imports loadedModules
142 Expression ls -> do
143 Expression ls -> do
143− let returned = unlines $ ["return ("] ++ ls ++ [")"]
144− case P.runIndentParser "" (P.whiteSpace *> P.parseValue <* Parsec.eof) returned of
144+ case P.runIndentParser "" (P.whiteSpace *> P.parseValue <* Parsec.eof) (unlines ls) of
145 Left err -> outputStrLn (show err)
145 Left err -> outputStrLn (show err)
146 Right decl -> handleDeclaration loadedModules imports decl
146 Right decl -> handleDeclaration loadedModules imports decl
147 go imports loadedModules
147 go imports loadedModules