Skip to content

Commit c5fee1d

Browse files
authored
Move to LTS 13.7 and tidy up some repo-merge bits (#105)
* Update to LTS 13.7 * LTS 13.7 & tighten warnings * More name changes to catch up with repo-merge * Revert some WIP * Temporary comment out WIP csv stuff
1 parent 9629198 commit c5fee1d

File tree

19 files changed

+96
-49
lines changed

19 files changed

+96
-49
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*.stack-work
22
/.dir-locals.el
3-
/eucalypt-hs.cabal
3+
*.cabal
44
/harness/.build

app/Main.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Eucalypt.Driver.Options
55
import Eucalypt.Driver.Explain (explain)
66
import Eucalypt.Driver.Evaluator (evaluate)
77
import System.Exit
8-
import Paths_eucalypt_hs (version)
8+
import Paths_eucalypt (version)
99
import Data.Version (showVersion)
1010

1111
-- | Primary banner for version data

ci/release.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def main(args):
6060
commit = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode('utf8').strip("'")
6161

6262
# TGZ the exe
63-
package = "eucalypt-hs-" + arch + ".tgz"
63+
package = "eucalypt-" + arch + ".tgz"
6464
with tarfile.open(package, "w:gz") as tar:
6565
tar.add(exe_path)
6666

package.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: eucalypt-hs
1+
name: eucalypt
22
version: 0.1.1.0
33
github: "curvelogic/eucalypt"
44
license: MIT
@@ -24,6 +24,7 @@ library:
2424
- array
2525
- bound
2626
- bytestring
27+
- cassava
2728
- comonad
2829
- conduit
2930
- containers
@@ -74,15 +75,15 @@ executables:
7475
- -rtsopts
7576
- -with-rtsopts=-N
7677
dependencies:
77-
- eucalypt-hs
78+
- eucalypt
7879
- optparse-applicative
7980
- directory
8081
- filepath
8182
- path
8283
- network-uri
8384

8485
tests:
85-
eucalypt-hs-test:
86+
eucalypt-test:
8687
main: Spec.hs
8788
source-dirs: test
8889
ghc-options:
@@ -97,7 +98,7 @@ tests:
9798
- bytestring
9899
- conduit
99100
- containers
100-
- eucalypt-hs
101+
- eucalypt
101102
- hspec
102103
- hspec-megaparsec
103104
- libyaml

src/Eucalypt/Core/AnonSyn.hs

+28-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,34 @@ Maintainer : [email protected]
77
Stability : experimental
88
-}
99

10-
module Eucalypt.Core.AnonSyn where
10+
module Eucalypt.Core.AnonSyn (
11+
bif,
12+
infixl_,
13+
infixr_,
14+
prefix_,
15+
postfix_,
16+
var,
17+
int,
18+
lam,
19+
letexp,
20+
letblock,
21+
app,
22+
soup,
23+
args,
24+
block,
25+
str,
26+
sym,
27+
withMeta,
28+
element,
29+
corename,
30+
corelist,
31+
corenull,
32+
corebool,
33+
corelookup,
34+
dynlookup,
35+
unresolved,
36+
Syn.CoreExpr)
37+
where
1138

1239
import Eucalypt.Core.SourceMap
1340
import qualified Eucalypt.Core.Syn as Syn

src/Eucalypt/Core/Cook.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ cookBottomUp _ e = Right e
151151

152152
-- | Run the shunting algorithm until finished or errored
153153
shunt ::
154-
(Show a, Anaphora SymbolicAnaphora a)
154+
(Anaphora SymbolicAnaphora a)
155155
=> State (ShuntState a) (Either CoreError (CoreExp a))
156156
shunt = (shunt1 `untilM_` finished) >> result
157157
where

src/Eucalypt/Core/Metadata.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ determineTarget meta = (, doc, format) <$> target
137137

138138

139139

140-
importsFromMetadata :: ToCoreBindingName a => CoreExp a -> Maybe [Input]
140+
importsFromMetadata :: CoreExp a -> Maybe [Input]
141141
importsFromMetadata m =
142142
readUnevaluatedMetadata "import" m extract
143143
where

src/Eucalypt/Core/Syn.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ isAnaphoricVar t (CoreVar _ s) = isAnaphor t s
517517
isAnaphoricVar _ _ = False
518518

519519
-- | Apply a number to the unnumbered anaphor
520-
applyNumber :: (Anaphora t a, Eq a) => t -> a -> State Int a
520+
applyNumber :: (Anaphora t a) => t -> a -> State Int a
521521
applyNumber t s | s == unnumberedAnaphor t = do
522522
n <- get
523523
put (n + 1)

src/Eucalypt/Driver/Core.hs

+11-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Control.Monad (forM_)
2424
import Control.Monad.Loops (iterateUntilM)
2525
import Control.Monad.State.Strict
2626
import qualified Data.ByteString as BS
27+
-- import qualified Data.ByteString.Lazy as BL
2728
import Data.Either (partitionEithers, rights)
2829
import Data.Foldable (toList)
2930
import qualified Data.Map as M
@@ -44,6 +45,7 @@ import Eucalypt.Driver.Lib (getResource)
4445
import Eucalypt.Driver.Options (EucalyptOptions(..))
4546
import Eucalypt.Reporting.Error (EucalyptError(..))
4647
import Eucalypt.Source.Error (DataParseException(..))
48+
-- import Eucalypt.Source.CsvSource
4749
import Eucalypt.Source.TextSource
4850
import Eucalypt.Source.TomlSource
4951
import Eucalypt.Source.YamlSource
@@ -241,6 +243,7 @@ loadUnit i@(Input locator name format) = do
241243
"toml" -> tomlDataToCore i source
242244
"yaml" -> activeYamlToCore i source
243245
"json" -> yamlDataToCore i source
246+
-- "csv" -> csvDataToCore i source
244247
"eu" -> eucalyptToCore i firstSMID source
245248
_ -> (return . Left . Command . InvalidInput) i
246249
case coreUnit of
@@ -255,7 +258,8 @@ loadUnit i@(Input locator name format) = do
255258
Right expr ->
256259
(return . Right . maybeApplyName . translateToCore input smid) expr
257260
yamlDataToCore input text = do
258-
r <- try (parseYamlExpr (show locator) text) :: IO (Either DataParseException CoreExpr)
261+
r <-
262+
try (parseYamlExpr (show locator) text) :: IO (Either DataParseException CoreExpr)
259263
case r of
260264
Left e -> (return . Left . Source) e
261265
Right core -> (return . Right . maybeApplyName . dataUnit input) core
@@ -266,15 +270,18 @@ loadUnit i@(Input locator name format) = do
266270
parseTomlData text >>=
267271
(return . Right . maybeApplyName <$> dataUnit input)
268272
activeYamlToCore input text = do
269-
r <- try (parseYamlExpr (show locator) text) :: IO (Either DataParseException CoreExpr)
273+
r <-
274+
try (parseYamlExpr (show locator) text) :: IO (Either DataParseException CoreExpr)
270275
case r of
271276
Left e -> (return . Left . Source) e
272277
Right core -> (return . Right . maybeApplyName . dataUnit input) core
273-
278+
-- csvDataToCore input text =
279+
-- parseCsv (BL.fromStrict text) >>=
280+
-- (return . Right . maybeApplyName <$> dataUnit input)
274281

275282

276283
-- | Parse units, reporting and exiting on error
277-
loadUnits :: (Traversable t, Foldable t) => t Input -> CoreLoad [TranslationUnit]
284+
loadUnits :: Traversable t => t Input -> CoreLoad [TranslationUnit]
278285
loadUnits inputs = do
279286
asts <- traverse loadUnit inputs
280287
case partitionEithers (toList asts) of

src/Eucalypt/Driver/Stg.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ debugMachine = initDebugMachineState
6565

6666
-- | Useful for comparing speed of conduit render pipelines with raw
6767
-- evaluation.
68-
runHeadless :: (MonadUnliftIO m, MonadIO m, MonadThrow m, MonadCatch m)
68+
runHeadless :: (MonadUnliftIO m, MonadCatch m)
6969
=> EucalyptOptions
7070
-> CoreExpr
7171
-> m ()
@@ -92,7 +92,7 @@ runHeadless opts expr = do
9292
-- | Build a conduit streaming pipeline where the machine generates
9393
-- events and renderer processes them.
9494
renderConduit ::
95-
(MonadUnliftIO m, MonadIO m, MonadThrow m, MonadCatch m)
95+
(MonadUnliftIO m, MonadCatch m)
9696
=> EucalyptOptions
9797
-> CoreExpr
9898
-> m BS.ByteString
@@ -114,7 +114,7 @@ renderConduit opts expr = handle handler $ do
114114
-- | Step through the machine yielding events via the conduit pipeline
115115
-- at each stage
116116
machineSource ::
117-
(MonadUnliftIO m, MonadResource m, MonadIO m, MonadThrow m)
117+
(MonadUnliftIO m, MonadThrow m)
118118
=> MachineState
119119
-> ConduitT () Event m ()
120120
machineSource ms = do

src/Eucalypt/Source/Error.hs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ data DataParseException
2525
| YamlParseError !String !String !String !Int !Int
2626
| FromYamlException Text
2727
| FromTomlException Text
28+
| FromCsvException Text
2829
deriving (Eq, Typeable)
2930

3031
instance Show DataParseException where
@@ -34,6 +35,7 @@ instance Show DataParseException where
3435
show (YamlParseError msg ctxt locator _line _col) = locator ++ ": " ++ msg ++ " " ++ ctxt
3536
show (FromYamlException ye) = "Error reading YAML: " ++ unpack ye
3637
show (FromTomlException te) = "Error reading TOML: " ++ unpack te
38+
show (FromCsvException te) = "Error reading CSV: " ++ unpack te
3739

3840
instance Exception DataParseException
3941

src/Eucalypt/Source/YamlSource.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ data RawExpr =
3939
-- | A scheme for translating YAML into Eucalypt core syntax
4040
class YamlTranslator a where
4141
handleScalar ::
42-
(Monad m, MonadThrow m)
42+
(MonadThrow m)
4343
=> a
4444
-> BS.ByteString
4545
-> Tag
4646
-> Style
4747
-> Anchor
4848
-> m CoreExpr
4949
handleList ::
50-
(Monad m, MonadThrow m)
50+
(MonadThrow m)
5151
=> a
5252
-> [CoreExpr]
5353
-> Tag
@@ -58,7 +58,7 @@ class YamlTranslator a where
5858
-- | Called to translate a mapping, with binding names, key
5959
-- expression and value expressions
6060
handleMapping ::
61-
(Monad m, MonadThrow m)
61+
(MonadThrow m)
6262
=> a
6363
-> [(Text, CoreExpr, CoreExpr)]
6464
-> Tag
@@ -110,7 +110,7 @@ parseBool _ = False
110110
-- @
111111
-- x: !eu 25 * 23
112112
-- @
113-
expressionFromString :: (Monad m, MonadThrow m) => String -> m CoreExpr
113+
expressionFromString :: MonadThrow m => String -> m CoreExpr
114114
expressionFromString s =
115115
case parseExpression s "YAML embedding" of
116116
Left err -> throwM err
@@ -123,7 +123,7 @@ expressionFromString s =
123123
-- @
124124
-- x: !eu::fn (x, y, z) x + y + z
125125
-- @
126-
lambdaExpressionFromString :: (Monad m, MonadThrow m) => String -> m CoreExpr
126+
lambdaExpressionFromString :: MonadThrow m => String -> m CoreExpr
127127
lambdaExpressionFromString s =
128128
case parseLambda s "YAML embedded function" of
129129
Left err -> throwM err

src/Eucalypt/Stg/Compiler/CompileCore.hs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
12
{-# LANGUAGE RecursiveDo #-}
23
{-|
34
Module : Eucalypt.Stg.Compiler.CompileCore

src/Eucalypt/Stg/Eval.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ applyOver ms _ref arity cs env le lf xs =
135135

136136
-- | Partially apply closure when we have too few arguments
137137
applyUnder ::
138-
(MonadIO m, MonadThrow m)
138+
(MonadIO m)
139139
=> MachineState
140140
-> Address
141141
-> ValVec
@@ -191,7 +191,7 @@ applyPartialOver ms arity cs env args le lf xs =
191191

192192
-- | Partially apply closure when we have too few arguments
193193
applyPartialUnder ::
194-
(MonadIO m, MonadThrow m)
194+
(MonadIO m)
195195
=> MachineState
196196
-> Address
197197
-> ValVec

src/Eucalypt/Stg/Intrinsics/Common.hs

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ readNatListReturn :: MachineState -> IO [Native]
109109
readNatListReturn ms =
110110
case ms of
111111
MachineState {machineCode = (ReturnCon TagCons xs Nothing)} ->
112-
let (StgNat h _ :< (StgAddr t :< _)) = asSeq xs
113-
in (h :) <$> readNatList ms t
112+
case asSeq xs of
113+
(StgNat h _ :< (StgAddr t :< _)) -> (h :) <$> readNatList ms t
114+
_ -> throwIn ms IntrinsicExpectedNativeList
114115
MachineState {machineCode = (ReturnCon TagNil _ Nothing)} -> return []
115116
_ -> throwIn ms IntrinsicExpectedNativeList
116117

src/Eucalypt/Stg/Intrinsics/Emit.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
12
{-# LANGUAGE RecordWildCards #-}
23
{-# LANGUAGE OverloadedStrings #-}
34
{-|
@@ -90,7 +91,7 @@ getValue ms a k = do
9091
-- (representing metadata) excavate out a native value for the
9192
-- specified key.
9293
--
93-
-- Gruesome.
94+
-- Gruesome. TODO: incomplete uni patterns
9495
excavate :: MachineState -> Symbol -> Address -> IO (Maybe Native)
9596
excavate ms k a = do
9697
obj <- peek a

src/Eucalypt/Stg/Scrapers.hs

+25-19
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ instance Scrapeable a => Scrapeable [a] where
5656
obj <- peek addr
5757
case obj of
5858
Closure { closureEnv = e
59-
, closureCode = LambdaForm {lamBody = (App (Con TagCons) xs)}
60-
} -> do
61-
let (h :< (t :< _)) = asSeq $ values (e, ms) $ nativeToValue <$> xs
62-
h' <- scrape ms h :: IO (Maybe a)
63-
t' <- scrape ms t :: IO (Maybe [a])
64-
return $ (:) <$> h' <*> t'
59+
, closureCode = LambdaForm {lamBody = expr@(App (Con TagCons) xs)}
60+
} ->
61+
case asSeq $ values (e, ms) $ nativeToValue <$> xs of
62+
(h :< (t :< _)) -> do
63+
h' <- scrape ms h :: IO (Maybe a)
64+
t' <- scrape ms t :: IO (Maybe [a])
65+
return $ (:) <$> h' <*> t'
66+
_ -> throwIn ms $ IntrinsicExpectedEvaluatedList expr
6567
Closure {closureCode = LambdaForm {lamBody = (App (Con TagNil) _)}} ->
6668
return $ Just []
6769
Closure {closureCode = lf} ->
@@ -76,14 +78,16 @@ instance (Scrapeable k, Scrapeable v) => Scrapeable (k, v) where
7678
obj <- peek addr
7779
case obj of
7880
Closure { closureEnv = e
79-
, closureCode = LambdaForm {lamBody = (App (Con TagCons) xs)}
80-
} -> do
81-
let (h :< (t :< _)) = asSeq $ values (e, ms) $ nativeToValue <$> xs
82-
k <- scrape ms h :: IO (Maybe k)
83-
t' <- scrape ms t :: IO (Maybe [v])
84-
case t' of
85-
(Just (v:_)) -> return $ (,) <$> k <*> Just v
86-
_ -> throwIn ms IntrinsicBadPair
81+
, closureCode = LambdaForm {lamBody = expr@(App (Con TagCons) xs)}
82+
} ->
83+
case asSeq $ values (e, ms) $ nativeToValue <$> xs of
84+
(h :< (t :< _)) -> do
85+
k <- scrape ms h :: IO (Maybe k)
86+
t' <- scrape ms t :: IO (Maybe [v])
87+
case t' of
88+
(Just (v:_)) -> return $ (,) <$> k <*> Just v
89+
_ -> throwIn ms IntrinsicBadPair
90+
_ -> throwIn ms $ IntrinsicExpectedEvaluatedList expr
8791
Closure {closureCode = lf} ->
8892
throwIn ms $ IntrinsicExpectedEvaluatedList (lamBody lf)
8993
BlackHole -> throwIn ms IntrinsicExpectedListFoundBlackHole
@@ -105,11 +109,13 @@ instance Scrapeable k => Scrapeable (BareCons k) where
105109
obj <- peek addr
106110
case obj of
107111
Closure { closureEnv = e
108-
, closureCode = LambdaForm {lamBody = (App (Con TagCons) xs)}
109-
} -> do
110-
let (h :< (t :< _)) = asSeq $ values (e, ms) $ nativeToValue <$> xs
111-
k <- scrape ms h
112-
return $ BareCons <$> k <*> pure t
112+
, closureCode = LambdaForm {lamBody = expr@(App (Con TagCons) xs)}
113+
} ->
114+
case asSeq $ values (e, ms) $ nativeToValue <$> xs of
115+
(h :< (t :< _)) -> do
116+
k <- scrape ms h
117+
return $ BareCons <$> k <*> pure t
118+
_ -> throwIn ms $ IntrinsicExpectedEvaluatedList expr
113119
Closure {closureCode = lf} ->
114120
throwIn ms $ IntrinsicExpectedEvaluatedList (lamBody lf)
115121
BlackHole -> throwIn ms IntrinsicExpectedListFoundBlackHole

stack.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
resolver: lts-13.2
1+
resolver: lts-13.7
22
packages:
33
- '.'
44
ghc-options:
5-
eucalypt-hs: -Wall -Werror
5+
eucalypt: -Wall -Werror -Wincomplete-uni-patterns -Wredundant-constraints

test/Eucalypt/Stg/Intrinsics/CommonSpec.hs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
{-|
34
Module : Eucalypt.Stg.Intrinsics.CommonSpec

0 commit comments

Comments
 (0)