Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
32f5b5d8
Commit
32f5b5d8
authored
Dec 12, 2013
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chaned IHaskellDisplay to just try it and fail instead of typechecking
parent
66e9e6a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
Evaluate.hs
IHaskell/Eval/Evaluate.hs
+15
-2
No files found.
IHaskell/Eval/Evaluate.hs
View file @
32f5b5d8
...
...
@@ -27,6 +27,7 @@ import Language.Haskell.Exts.Syntax hiding (Name, Type)
import
InteractiveEval
import
DynFlags
import
Type
import
Exception
(
gtry
)
import
HscTypes
import
HscMain
import
TcType
...
...
@@ -227,6 +228,7 @@ evalCommand (Expression expr) = do
case
success
of
Failure
->
return
(
success
,
out
)
Success
->
do
{-
-- Get the type of the output expression.
outType <- exprType "it"
...
...
@@ -237,12 +239,18 @@ evalCommand (Expression expr) = do
{-
liftIO $ print $ (showSDoc flags . ppr) outType
liftIO $ print $ map (showSDoc flags . ppr) displayTypes
liftIO $ print $ map (showSDoc flags . ppr . tyVarsOfType) (outType:displayTypes)
liftIO $ print $ map (instanceMatches outType) displayTypes
-}
liftIO $ print $ (showSDoc flags . ppr) outType
liftIO $ print $ (showSDoc flags . ppr) (head displayTypes)
liftIO $ print $ map (showSDoc flags . ppr . tyVarsOfType) (outType:displayTypes)
-- Check if any of the instances match our expression type.
if any (instanceMatches outType) displayTypes
-}
canRunDisplay
<-
attempt
$
exprType
"IHaskell.Display.display it"
if
canRunDisplay
then
do
-- If there are instance matches, convert the object into
-- a [DisplayData]. We also serialize it into a bytestring. We get
...
...
@@ -251,7 +259,7 @@ evalCommand (Expression expr) = do
-- attempting to do this without the serialization to binary and
-- back gives very strange errors - all the types match but it
-- refuses to decode back into a [DisplayData].
displayedBytestring
<-
dynCompileExpr
"Serialize.encode (display it)"
displayedBytestring
<-
dynCompileExpr
"Serialize.encode (
IHaskell.Display.
display it)"
case
fromDynamic
displayedBytestring
of
Nothing
->
error
"Expecting lazy Bytestring"
Just
bytestring
->
...
...
@@ -263,6 +271,11 @@ evalCommand (Expression expr) = do
else
return
(
success
,
out
)
where
attempt
::
Interpreter
a
->
Interpreter
Bool
attempt
action
=
gcatch
(
action
>>
return
True
)
failure
where
failure
::
SomeException
->
Interpreter
Bool
failure
_
=
return
False
instanceMatches
::
Type
->
Type
->
Bool
instanceMatches
exprType
instanceType
=
case
tcMatchTy
(
tyVarsOfType
instanceType
)
instanceType
exprType
of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment