Commit 9d3167b8 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Reorganization to move all evaluators into Eval/

parent ab5b30e2
......@@ -163,20 +163,23 @@
"metadata": {},
"outputs": [
{
"html": [
"<span style='color: red; font-style: italic;'>IHaskell/Eval/Evaluate.hs:207:58-84: Non-exhaustive patterns in lambda<br/></span>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 10,
"text": []
},
{
"metadata": {},
"output_type": "display_data"
}
],
"prompt_number": 9
"prompt_number": 10
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"f 3"
"f 2"
],
"language": "python",
"metadata": {},
......@@ -184,9 +187,9 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 7,
"prompt_number": 11,
"text": [
"2\n"
"3\n"
]
},
{
......@@ -194,13 +197,13 @@
"output_type": "display_data"
}
],
"prompt_number": 7
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"f 2"
"it11"
],
"language": "python",
"metadata": {},
......@@ -208,7 +211,7 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 8,
"prompt_number": 12,
"text": [
"3\n"
]
......@@ -218,7 +221,7 @@
"output_type": "display_data"
}
],
"prompt_number": 8
"prompt_number": 12
},
{
"cell_type": "code",
......
......@@ -51,7 +51,8 @@ executable IHaskell
-- Modules included in this executable, other than Main.
other-modules:
IHaskell.Completion
IHaskell.Eval.Completion
IHaskell.Eval.Info
IHaskell.Eval.Evaluate
IHaskell.IPython
IHaskell.Message.Parser
......
......@@ -14,7 +14,7 @@
names should not be confused by the third option.
-}
module IHaskell.Completion (makeCompletions) where
module IHaskell.Eval.Completion (makeCompletions) where
import Prelude
import Data.List (find, isPrefixOf, nub)
......
......@@ -6,7 +6,8 @@
This module exports all functions used for evaluation of IHaskell input.
-}
module IHaskell.Eval.Evaluate (
interpret, evaluate, Interpreter, liftIO
interpret, evaluate, Interpreter, liftIO,
typeCleaner
) where
import ClassyPrelude hiding (liftIO, hGetContents)
......@@ -38,7 +39,13 @@ debug :: Bool
debug = True
ignoreTypePrefixes :: [String]
ignoreTypePrefixes = ["GHC.Types", "GHC.Base"]
ignoreTypePrefixes = ["GHC.Types", "GHC.Base", "GHC.Show", "System.IO"]
typeCleaner :: String -> String
typeCleaner = useStringType . foldl' (.) id (map (`replace` "") fullPrefixes)
where
fullPrefixes = map (++ ".") ignoreTypePrefixes
useStringType = replace "[Char]" "String"
makeWrapperStmts :: (String, [String], [String])
makeWrapperStmts = (fileName, initStmts, postStmts)
......@@ -312,8 +319,9 @@ parseStmts code =
returnStmt = "return ()"
makeError :: String -> String
makeError = printf "<span style='color: red; font-style: italic;'>%s</span>" . replace "\n" "<br/>" . dropper
where dropper = foldl' (.) useStringType (map (`replace` "") dropList)
dropList = useDashV : map (++ ".") ignoreTypePrefixes
makeError = printf "<span style='color: red; font-style: italic;'>%s</span>" .
replace "\n" "<br/>" .
replace useDashV "" .
typeCleaner
where
useDashV = "\nUse -v to see a list of the files searched for."
useStringType = replace "[Char]" "String"
......@@ -16,9 +16,10 @@ import IHaskell.Types
import IHaskell.ZeroMQ
import qualified IHaskell.Message.UUID as UUID
import IHaskell.Eval.Evaluate
import IHaskell.Eval.Completion (makeCompletions)
import IHaskell.Eval.Info
import qualified Data.ByteString.Char8 as Chars
import IHaskell.IPython
import IHaskell.Completion (makeCompletions)
import GHC
import Outputable (showSDoc, ppr)
......@@ -179,16 +180,11 @@ replyTo _ creq@CompleteRequest{} replyHeader state = do
-- | Reply to the object_info_request message. Given an object name, return
-- | the associated type calculated by GHC.
replyTo _ ObjectInfoRequest{objectName=oname} replyHeader state = do
dflags <- getSessionDynFlags
maybeDocs <- flip gcatch (\(_::SomeException) -> return Nothing) $ do
result <- exprType . Chars.unpack $ oname
let docs = showSDoc dflags . ppr $ result
return (Just docs)
let docs = fromMaybe "" maybeDocs
docs <- info $ Chars.unpack oname
let reply = ObjectInfoReply {
header = replyHeader,
objectName = oname,
objectFound = isJust maybeDocs,
objectFound = docs == "",
objectTypeString = Chars.pack docs,
objectDocString = Chars.pack docs
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment