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
79b68829
Commit
79b68829
authored
Dec 12, 2013
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old typechecking code
parent
32f5b5d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
43 deletions
+6
-43
Evaluate.hs
IHaskell/Eval/Evaluate.hs
+6
-43
No files found.
IHaskell/Eval/Evaluate.hs
View file @
79b68829
...
...
@@ -228,27 +228,10 @@ evalCommand (Expression expr) = do
case
success
of
Failure
->
return
(
success
,
out
)
Success
->
do
{-
-- Get the type of the output expression.
outType <- exprType "it"
-- Get all the types that match the IHaskellData typeclass.
displayTypes <- getIHaskellDisplayInstances
flags <- getSessionDynFlags
{-
liftIO $ print $ (showSDoc flags . ppr) outType
liftIO $ print $ map (showSDoc flags . ppr) 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
-}
-- Try to use `display` to convert our type into the output
-- DisplayData. If typechecking fails and there is no appropriate
-- typeclass, this will throw an exception and thus `attempt` will
-- return False, and we just resort to plaintext.
canRunDisplay
<-
attempt
$
exprType
"IHaskell.Display.display it"
if
canRunDisplay
then
do
...
...
@@ -271,33 +254,13 @@ evalCommand (Expression expr) = do
else
return
(
success
,
out
)
where
-- Try to evaluate an action. Return True if it succeeds and False if
-- it throws an exception. The result of the action is discarded.
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
Nothing
->
False
Just
_
->
True
getIHaskellDisplayInstances
::
GhcMonad
m
=>
m
[
Type
]
getIHaskellDisplayInstances
=
withSession
$
\
hscEnv
->
do
ident
<-
liftIO
$
unLoc
<$>
hscParseIdentifier
hscEnv
"IHaskellDisplay"
names
<-
liftIO
$
hscTcRnLookupRdrName
hscEnv
ident
case
names
of
[]
->
return
[]
[
name
]
->
do
maybeThings
<-
liftIO
$
hscTcRnGetInfo
hscEnv
name
case
maybeThings
of
Nothing
->
return
[]
-- Just get the first type in the instances, because we know
-- that the IHaskellDisplay typeclass only has one type
-- argument. Return these types, as these are the ones with
-- a match.
Just
(
_
,
_
,
instances
)
->
return
$
map
(
head
.
is_tys
)
instances
evalCommand
(
Declaration
decl
)
=
wrapExecution
$
runDecls
decl
>>
return
[]
evalCommand
(
ParseError
loc
err
)
=
wrapExecution
$
...
...
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