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

Reorganization to move all evaluators into Eval/

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