Skip to content

Commit 33332af

Browse files
authored
install the correct version of cabal (#90)
* two mismatched GHC version numbers were listed in .travis.yml * bump CI to ghc-8.8.2 * bump CI to cabal-install-3.2 even for older GHCs * build dependencies in dist-newstyle, do not install them in ~/.ghci * move the cd command to example.hs * validate the output of example.hs Fixes #89
1 parent 01ea049 commit 33332af

File tree

3 files changed

+49
-15
lines changed

3 files changed

+49
-15
lines changed

.travis.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@ language: c
33

44
matrix:
55
include:
6-
- env: CABALVER=2.2 GHCVER=8.4.4
7-
addons: {apt: {packages: [cabal-install-2.2, ghc-8.4.4], sources: [hvr-ghc]}}
8-
- env: CABALVER=2.4 GHCVER=8.6.5
9-
addons: {apt: {packages: [cabal-install-2.4, ghc-8.6.5], sources: [hvr-ghc]}}
10-
- env: CABALVER=2.6 GHCVER=8.8.1
11-
addons: {apt: {packages: [cabal-install-2.4, ghc-8.8.1], sources: [hvr-ghc]}}
12-
- env: CABALVER=2.6 GHCVER=8.8.1 CONFIG_OPTS=--enable-executable-dynamic
13-
addons: {apt: {packages: [cabal-install-2.4, ghc-8.8.1], sources: [hvr-ghc]}}
6+
- env: CABALVER=3.2 GHCVER=8.4.4
7+
addons: {apt: {packages: [cabal-install-3.2, ghc-8.4.4], sources: [hvr-ghc]}}
8+
- env: CABALVER=3.2 GHCVER=8.6.5
9+
addons: {apt: {packages: [cabal-install-3.2, ghc-8.6.5], sources: [hvr-ghc]}}
10+
- env: CABALVER=3.2 GHCVER=8.8.2
11+
addons: {apt: {packages: [cabal-install-3.2, ghc-8.8.2], sources: [hvr-ghc]}}
12+
- env: CABALVER=3.2 GHCVER=8.8.2 CONFIG_OPTS=--enable-executable-dynamic
13+
addons: {apt: {packages: [cabal-install-3.2, ghc-8.8.2], sources: [hvr-ghc]}}
1414

1515
cache:
1616
directories:
1717
- $HOME/.cabal/
1818
- $HOME/.ghc/
19-
- dist/
19+
- dist-newstyle/
2020

2121
before_install:
2222
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
2323

2424
install:
2525
- travis_retry cabal update
26-
- cabal install --only-dependencies --enable-tests
26+
- cabal v2-build --only-dependencies --enable-tests
2727

2828
script:
29-
- cabal configure --enable-tests $CONFIG_OPTS
30-
- cabal test
31-
- cabal install
32-
- (cd examples && runghc example.hs)
29+
- cabal v2-test
30+
- cabal v2-exec -- runghc examples/example.hs | diff examples/expected.txt -

examples/example.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import Data.List
22

33
import Control.Monad
44
import Language.Haskell.Interpreter
5+
import System.Directory
56

67
main :: IO ()
7-
main = do r <- runInterpreter testHint
8+
main = do setCurrentDirectory "examples"
9+
r <- runInterpreter testHint
810
case r of
911
Left err -> putStrLn $ errorString err
1012
Right () -> return ()

examples/expected.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Load SomeModule.hs
2+
3+
Put the Prelude, Data.Map and *SomeModule in scope
4+
Data.Map is qualified as M!
5+
6+
Now we can query the type of an expression
7+
e.g. typeOf M.singleton (f, g, h, 42)
8+
Num d => a1 -> M.Map ([a2] -> a2, [a3] -> a3, [a4] -> a4, d) a1
9+
10+
Observe that f, g and h are defined in SomeModule.hs, but f is not exported. Let's check it...
11+
[Fun "g",Fun "h"]
12+
13+
We can also evaluate an expression; the result will be a string
14+
e.g. eval "length $ concat [[f,g],[h]]"
15+
"3"
16+
17+
Or we can interpret it as a proper, say, int value!
18+
3
19+
20+
This works for any monomorphic type, even for function types
21+
e.g. we interpret \(Just x) -> succ x with type Maybe Int -> Int and apply it on Just 7
22+
8
23+
24+
And sometimes we can even use the type system to infer the expected type (eg Maybe Bool -> Bool)!
25+
False
26+
27+
Here we evaluate an expression of type string, that when evaluated (again) leads to a string
28+
Worked!
29+
30+
We can also execute statements in the IO monad and bind new names, e.g.
31+
x <- return 42
32+
print x
33+
42
34+

0 commit comments

Comments
 (0)