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
cd9688f0
Commit
cd9688f0
authored
Apr 24, 2021
by
Vaibhav Sagar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ihaskell: update
parent
584127f8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
143 additions
and
21 deletions
+143
-21
ihaskell.cabal
ihaskell.cabal
+8
-4
Completion.hs
src/IHaskell/Eval/Completion.hs
+14
-0
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+71
-9
Info.hs
src/IHaskell/Eval/Info.hs
+9
-0
Inspect.hs
src/IHaskell/Eval/Inspect.hs
+8
-0
Util.hs
src/IHaskell/Eval/Util.hs
+29
-7
Eval.hs
src/tests/IHaskell/Test/Eval.hs
+4
-1
No files found.
ihaskell.cabal
View file @
cd9688f0
...
...
@@ -63,13 +63,13 @@ library
cmdargs >=0.10,
containers >=0.5,
directory -any,
exceptions -any,
filepath -any,
ghc >=8.0,
ghc-parser >=0.2.1,
ghc-paths >=0.1,
haskeline -any,
hlint >=1.9,
haskell-src-exts >=1.18,
http-client >= 0.4,
http-client-tls >= 0.2,
mtl >=2.1,
...
...
@@ -88,7 +88,11 @@ library
utf8-string -any,
vector -any,
ipython-kernel >=0.10.2.0,
ghc-boot >=8.0 && <8.11
ghc-boot >=8.0 && <9.1
if impl (ghc < 8.10)
build-depends:
haskell-src-exts >=1.18
exposed-modules: IHaskell.Display
IHaskell.Convert
...
...
@@ -135,10 +139,10 @@ executable ihaskell
default-language: Haskell2010
build-depends:
ihaskell -any,
base >=4.9 && < 4.1
5
,
base >=4.9 && < 4.1
6
,
text >=0.11,
transformers -any,
ghc >=8.0 && <
8.1
1,
ghc >=8.0 && <
9.
1,
process >=1.1,
aeson >=0.7,
bytestring >=0.10,
...
...
src/IHaskell/Eval/Completion.hs
View file @
cd9688f0
...
...
@@ -22,10 +22,18 @@ import qualified Data.List.Split.Internals as Split
import
System.Environment
(
getEnv
)
import
GHC
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
GHC.Unit.Database
import
GHC.Unit.State
import
GHC.Driver.Session
import
GHC.Driver.Monad
as
GhcMonad
import
GHC.Utils.Outputable
(
showPpr
)
#
else
import
GHC.PackageDb
import
DynFlags
import
GhcMonad
import
Outputable
(
showPpr
)
#
endif
import
System.Directory
import
Control.Exception
(
try
)
...
...
@@ -74,9 +82,15 @@ complete code posOffset = do
unqualNames
=
nub
$
filter
(
not
.
isQualified
)
rdrNames
qualNames
=
nub
$
scopeNames
++
filter
isQualified
rdrNames
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
let
Just
db
=
unitDatabases
flags
getNames
=
map
(
moduleNameString
.
exposedName
)
.
unitExposedModules
moduleNames
=
nub
$
concatMap
getNames
$
concatMap
unitDatabaseUnits
db
#
else
let
Just
db
=
pkgDatabase
flags
getNames
=
map
(
moduleNameString
.
exposedName
)
.
exposedModules
moduleNames
=
nub
$
concatMap
getNames
$
concatMap
snd
db
#
endif
let
target
=
completionTarget
line
pos
completion
=
completionType
line
pos
target
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
cd9688f0
...
...
@@ -28,7 +28,6 @@ import qualified Data.Set as Set
import
Data.Char
as
Char
import
Data.Dynamic
import
qualified
Data.Serialize
as
Serialize
import
qualified
Debugger
import
System.Directory
import
System.Posix.IO
(
fdToHandle
)
import
System.IO
(
hGetChar
,
hSetEncoding
,
utf8
)
...
...
@@ -38,18 +37,33 @@ import System.Exit
import
Data.Maybe
(
mapMaybe
)
import
System.Environment
(
getEnv
)
import
qualified
GHC.Paths
import
InteractiveEval
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
qualified
GHC.Runtime.Debugger
as
Debugger
import
GHC.Runtime.Eval
import
GHC.Driver.Session
import
GHC.Driver.Types
import
GHC.Unit.State
import
Control.Monad.Catch
as
MC
import
GHC.Utils.Outputable
hiding
((
<>
))
import
GHC.Data.Bag
import
GHC.Unit.Types
(
UnitId
)
import
qualified
GHC.Utils.Error
as
ErrUtils
#
else
import
qualified
Debugger
import
Bag
import
DynFlags
import
Exception
(
gtry
)
import
HscTypes
import
GhcMonad
(
liftIO
)
import
GHC
hiding
(
Stmt
,
TypeSig
)
import
InteractiveEval
import
Exception
(
gtry
)
import
Exception
hiding
(
evaluate
)
import
GhcMonad
(
liftIO
)
import
Outputable
hiding
((
<>
))
import
Packages
import
Bag
import
qualified
ErrUtils
#
endif
import
qualified
GHC.Paths
import
GHC
hiding
(
Stmt
,
TypeSig
)
import
IHaskell.Types
import
IHaskell.IPython
...
...
@@ -61,13 +75,31 @@ import IHaskell.Eval.Util
import
IHaskell.BrokenPackages
import
StringUtils
(
replace
,
split
,
strip
,
rstrip
)
#
if
MIN_VERSION_ghc
(
8
,
2
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
GHC.Data.FastString
#
elif
MIN_VERSION_ghc
(
8
,
2
,
0
)
import
FastString
(
unpackFS
)
#
else
import
Paths_ihaskell
(
version
)
import
Data.Version
(
versionBranch
)
#
endif
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
gcatch
::
Ghc
a
->
(
SomeException
->
Ghc
a
)
->
Ghc
a
gcatch
=
MC
.
catch
gtry
::
IO
a
->
IO
(
Either
SomeException
a
)
gtry
=
MC
.
try
gfinally
::
Ghc
a
->
Ghc
b
->
Ghc
a
gfinally
=
MC
.
finally
ghandle
::
(
MonadCatch
m
,
Exception
e
)
=>
(
e
->
m
a
)
->
m
a
->
m
a
ghandle
=
MC
.
handle
throw
::
SomeException
->
Ghc
a
throw
=
MC
.
throwM
#
endif
-- | Set GHC's verbosity for debugging
...
...
@@ -157,9 +189,19 @@ interpret libdir allowedStdin needsSupportLibraries action = runGhc (Just libdir
-- Run the rest of the interpreter
action
hasSupportLibraries
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
packageIdString'
::
DynFlags
->
UnitInfo
->
String
#
else
packageIdString'
::
DynFlags
->
PackageConfig
->
String
#
endif
packageIdString'
dflags
pkg_cfg
=
#
if
MIN_VERSION_ghc
(
8
,
2
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
case
(
lookupUnit
(
unitState
dflags
)
$
mkUnit
pkg_cfg
)
of
Nothing
->
"(unknown)"
Just
cfg
->
let
PackageName
name
=
unitPackageName
cfg
in
unpackFS
name
#
elif
MIN_VERSION_ghc
(
8
,
2
,
0
)
case
(
lookupPackage
dflags
$
packageConfigId
pkg_cfg
)
of
Nothing
->
"(unknown)"
Just
cfg
->
let
...
...
@@ -169,11 +211,19 @@ packageIdString' dflags pkg_cfg =
fromMaybe
"(unknown)"
(
unitIdPackageIdString
dflags
$
packageConfigId
pkg_cfg
)
#
endif
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
getPackageConfigs
::
DynFlags
->
[
GenUnitInfo
UnitId
]
getPackageConfigs
dflags
=
foldMap
unitDatabaseUnits
pkgDb
where
Just
pkgDb
=
unitDatabases
dflags
#
else
getPackageConfigs
::
DynFlags
->
[
PackageConfig
]
getPackageConfigs
dflags
=
foldMap
snd
pkgDb
where
Just
pkgDb
=
pkgDatabase
dflags
#
endif
-- | Initialize our GHC session with imports and a value for 'it'. Return whether the IHaskell
-- library is available.
...
...
@@ -183,7 +233,11 @@ initializeImports importSupportLibraries = do
-- version of the ihaskell library. Also verify that the packages we load are not broken.
dflags
<-
getSessionDynFlags
broken
<-
liftIO
getBrokenPackages
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
dflgs
<-
liftIO
$
initUnits
dflags
#
else
(
dflgs
,
_
)
<-
liftIO
$
initPackages
dflags
#
endif
let
db
=
getPackageConfigs
dflgs
packageNames
=
map
(
packageIdString'
dflgs
)
db
hiddenPackages
=
Set
.
intersection
hiddenPackageNames
(
Set
.
fromList
packageNames
)
...
...
@@ -786,7 +840,11 @@ evalCommand _ (Directive GetDoc query) state = safely state $ do
evalCommand
_
(
Directive
SPrint
binding
)
state
=
wrapExecution
state
$
do
flags
<-
getSessionDynFlags
contents
<-
liftIO
$
newIORef
[]
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
let
action
=
\
_dflags
_warn
_sev
_srcspan
msg
->
modifyIORef'
contents
(
showSDoc
flags
msg
:
)
#
else
let
action
=
\
_dflags
_sev
_srcspan
_ppr
_style
msg
->
modifyIORef'
contents
(
showSDoc
flags
msg
:
)
#
endif
let
flags'
=
flags
{
log_action
=
action
}
_
<-
setSessionDynFlags
flags'
Debugger
.
pprintClosureCommand
False
False
binding
...
...
@@ -1028,7 +1086,11 @@ doLoadModule name modName = do
_
<-
setSessionDynFlags
$
flip
gopt_set
Opt_BuildDynamicToo
flags
{
hscTarget
=
objTarget
flags
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
,
log_action
=
\
_dflags
_warn
_sev
_srcspan
msg
->
modifyIORef'
errRef
(
showSDoc
flags
msg
:
)
#
else
,
log_action
=
\
_dflags
_sev
_srcspan
_ppr
_style
msg
->
modifyIORef'
errRef
(
showSDoc
flags
msg
:
)
#
endif
}
-- Load the new target.
...
...
src/IHaskell/Eval/Info.hs
View file @
cd9688f0
...
...
@@ -8,11 +8,20 @@ import IHaskellPrelude
import
IHaskell.Eval.Evaluate
(
typeCleaner
,
Interpreter
)
import
GHC
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
GHC.Utils.Outputable
import
Control.Monad.Catch
(
handle
)
#
else
import
Outputable
import
Exception
#
endif
info
::
String
->
Interpreter
String
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
info
name
=
handle
handler
$
do
#
else
info
name
=
ghandle
handler
$
do
#
endif
dflags
<-
getSessionDynFlags
#
if
MIN_VERSION_ghc
(
8
,
2
,
0
)
result
<-
exprType
TM_Inst
name
...
...
src/IHaskell/Eval/Inspect.hs
View file @
cd9688f0
...
...
@@ -12,7 +12,11 @@ import qualified Prelude as P
import
Data.List.Split
(
splitOn
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
qualified
Control.Monad.Catch
as
MC
#
else
import
Exception
(
ghandle
)
#
endif
import
IHaskell.Eval.Evaluate
(
Interpreter
)
import
IHaskell.Display
...
...
@@ -44,7 +48,11 @@ inspect code pos = do
let
identifier
=
getIdentifier
code
pos
handler
::
SomeException
->
Interpreter
(
Maybe
a
)
handler
_
=
return
Nothing
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
response
<-
MC
.
handle
handler
(
Just
<$>
getType
identifier
)
#
else
response
<-
ghandle
handler
(
Just
<$>
getType
identifier
)
#
endif
let
prefix
=
identifier
++
" :: "
fmt
str
=
Display
[
plain
$
prefix
++
str
]
return
$
fmt
<$>
response
src/IHaskell/Eval/Util.hs
View file @
cd9688f0
...
...
@@ -33,12 +33,21 @@ import qualified Data.ByteString.Char8 as CBS
#
endif
-- GHC imports.
import
DynFlags
#
if
MIN_VERSION_ghc
(
8
,
6
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
import
GHC.Core.InstEnv
(
is_cls
,
is_tys
)
import
GHC.Core.Unify
import
GHC.Core.Ppr.TyThing
import
GHC.Driver.CmdLine
import
GHC.Driver.Monad
(
modifySession
)
import
GHC.Driver.Session
import
GHC.Driver.Types
import
GHC.Types.Name
(
pprInfixName
)
import
GHC.Types.Name.Set
import
qualified
GHC.Driver.Session
as
DynFlags
import
qualified
GHC.Utils.Outputable
as
O
import
qualified
GHC.Utils.Ppr
as
Pretty
#
else
import
FastString
#
endif
import
GHC
import
DynFlags
import
GhcMonad
import
HscTypes
import
NameSet
...
...
@@ -48,6 +57,12 @@ import InstEnv (ClsInst(..))
import
Unify
(
tcMatchTys
)
import
qualified
Pretty
import
qualified
Outputable
as
O
#
endif
#
if
MIN_VERSION_ghc
(
8
,
6
,
0
)
#
else
import
FastString
#
endif
import
GHC
import
Control.Monad
(
void
)
import
Data.Function
(
on
)
...
...
@@ -55,7 +70,8 @@ import Data.List (nubBy)
import
StringUtils
(
replace
)
#
if
MIN_VERSION_ghc
(
8
,
4
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
#
elif
MIN_VERSION_ghc
(
8
,
4
,
0
)
import
CmdLineParser
(
warnMsg
)
#
endif
...
...
@@ -228,7 +244,9 @@ doc :: GhcMonad m => O.SDoc -> m String
doc
sdoc
=
do
flags
<-
getSessionDynFlags
unqual
<-
getPrintUnqual
#
if
MIN_VERSION_ghc
(
8
,
2
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
let
style
=
O
.
mkUserStyle
unqual
O
.
AllTheWay
#
elif
MIN_VERSION_ghc
(
8
,
2
,
0
)
let
style
=
O
.
mkUserStyle
flags
unqual
O
.
AllTheWay
#
else
let
style
=
O
.
mkUserStyle
unqual
O
.
AllTheWay
...
...
@@ -270,7 +288,11 @@ initGhci sandboxPackages = do
case
sandboxPackages
of
Nothing
->
packageDBFlags
originalFlags
Just
path
->
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
let
pkg
=
PackageDB
$
PkgDbPath
path
#
else
let
pkg
=
PackageDB
$
PkgConfFile
path
#
endif
in
packageDBFlags
originalFlags
++
[
pkg
]
void
$
setSessionDynFlags
$
dflags
...
...
src/tests/IHaskell/Test/Eval.hs
View file @
cd9688f0
...
...
@@ -161,7 +161,10 @@ testEval =
":! printf
\"
hello
\\
nworld
\"
"
`
becomes
`
[
"hello
\n
world"
]
it
"evaluates directives"
$
do
#
if
MIN_VERSION_ghc
(
8
,
2
,
0
)
#
if
MIN_VERSION_ghc
(
9
,
0
,
0
)
-- brackets around the type variable
":typ 3"
`
becomes
`
[
"3 :: forall {p}. Num p => p"
]
#
elif
MIN_VERSION_ghc
(
8
,
2
,
0
)
-- It's `p` instead of `t` for some reason
":typ 3"
`
becomes
`
[
"3 :: forall p. Num p => p"
]
#
else
...
...
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