Skip to content

Commit 1e3d681

Browse files
committed
hlint and formatting
1 parent f1b8d24 commit 1e3d681

12 files changed

Lines changed: 97 additions & 101 deletions

File tree

app/Evaluare.hs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import Data.Text (Text)
1414
import qualified Data.Text as T
1515
import qualified Data.Text.Zipper as TZ
1616
import qualified Graphics.Vty as V
17-
import PrettyPrint (PrettierIExpr (..))
17+
import PrettyPrint (PrettyCompiledExpr (..))
1818
import Reflex
1919
import Reflex.Vty
2020
import System.Environment (getArgs)
2121
import qualified System.IO.Strict as Strict
2222
import qualified Telomare as Tel
23-
import Telomare (IExpr (..), IExprF (..))
23+
import Telomare (CompiledExpr, CompiledExprF (..), PartExprF (..), StuckF (..))
2424
import qualified Telomare.Eval as TE
2525
import Telomare.Parser (AnnotatedUPT, parseModule)
2626
import Text.Read (readMaybe)
@@ -120,45 +120,45 @@ nodeList e nodes0 = col $ do
120120
et <- grout flex $ nodes nodes0
121121
pure $ leftmost [e, et]
122122

123-
nodify :: Cofree IExprF (Int, IExpr) -> [Node]
123+
nodify :: Cofree CompiledExprF (Int, CompiledExpr) -> [Node]
124124
nodify = removeExtraNumbers . fmap go . allNodes 0 where
125125
removeExtraNumbers :: [Node] -> [Node]
126126
removeExtraNumbers = \case
127127
[] -> []
128128
(x:xs) -> case (readMaybe . T.unpack . _node_label $ x) :: Maybe Int of
129129
Nothing -> x : removeExtraNumbers xs
130130
Just i -> x : removeExtraNumbers (drop (2 * i) xs)
131-
go :: (Int, Cofree IExprF (Int, IExpr)) -> Node
131+
go :: (Int, Cofree CompiledExprF (Int, CompiledExpr)) -> Node
132132
go (i, x@(anno :< _)) =
133133
Node ( T.pack
134134
. (join (replicate i " ") <>)
135135
. head
136136
. lines
137137
. show
138-
. PrettierIExpr
138+
. PrettyCompiledExpr
139139
. Tel.forget
140140
$ x
141141
)
142142
( T.pack
143143
. (join (replicate i " ") <>)
144-
. (show . PrettierIExpr)
144+
. (show . PrettyCompiledExpr)
145145
. snd
146146
$ anno
147147
)
148148
False
149149
allNodes :: Int -- * Indentation
150-
-> Cofree IExprF (Int, IExpr)
151-
-> [(Int, Cofree IExprF (Int, IExpr))]
150+
-> Cofree CompiledExprF (Int, CompiledExpr)
151+
-> [(Int, Cofree CompiledExprF (Int, CompiledExpr))]
152152
allNodes i = \case
153-
x@(_ :< ZeroF) -> [(i, x)]
154-
x@(_ :< EnvF) -> [(i, x)]
155-
x@(_ :< TraceF) -> [(i, x)]
156-
x@(_ :< (SetEnvF a)) -> (i, x) : allNodes (i + 1) a
157-
x@(_ :< (DeferF a)) -> (i, x) : allNodes (i + 1) a
158-
x@(_ :< (PLeftF a)) -> (i, x) : allNodes (i + 1) a
159-
x@(_ :< (PRightF a)) -> (i, x) : allNodes (i + 1) a
160-
x@(_ :< (PairF a b)) -> (i, x) : allNodes (i + 1) a <> allNodes (i + 1) b
161-
x@(_ :< (GateF a b)) -> (i, x) : allNodes (i + 1) a <> allNodes (i + 1) b
153+
x@(_ :< CompiledExprB ZeroSF) -> [(i, x)]
154+
x@(_ :< CompiledExprB EnvSF) -> [(i, x)]
155+
x@(_ :< CompiledExprB (SetEnvSF a)) -> (i, x) : allNodes (i + 1) a
156+
x@(_ :< CompiledExprS (DeferSF _ a)) -> (i, x) : allNodes (i + 1) a
157+
x@(_ :< CompiledExprB (LeftSF a)) -> (i, x) : allNodes (i + 1) a
158+
x@(_ :< CompiledExprB (RightSF a)) -> (i, x) : allNodes (i + 1) a
159+
x@(_ :< CompiledExprB (PairSF a b)) -> (i, x) : allNodes (i + 1) a <> allNodes (i + 1) b
160+
x@(_ :< CompiledExprB (GateSF a b)) -> (i, x) : allNodes (i + 1) a <> allNodes (i + 1) b
161+
x -> [(i, x)]
162162

163163

164164
-- parseModule :: String -> Either String [Either AnnotatedUPT (String, AnnotatedUPT)]
@@ -207,7 +207,7 @@ main = do
207207
getout <- escOrCtrlcQuit
208208
tile flex . box (pure roundedBoxStyle) . row $ do
209209
rec
210-
eEitherIExpr :: Event t (Either String IExpr) <- grout flex . col $ do
210+
eEitherIExpr :: Event t (Either String CompiledExpr) <- grout flex . col $ do
211211
telomareTextInput :: TextInput t <- grout flex textBox
212212
pure . updated $ TE.eval2IExpr modules . T.unpack <$> _textInput_value telomareTextInput
213213
grout (fixed 2) . col . text $ ""

app/Repl.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ module Main where
1010

1111
import Control.Comonad.Cofree (Cofree (..))
1212
import qualified Control.Exception as Exception
13+
import Control.Monad.Identity (Identity, runIdentity)
1314
import Control.Monad.IO.Class
1415
import qualified Control.Monad.State as State
1516
import Data.Bifunctor (first)
16-
import Data.Fix (Fix (..))
1717
import Data.Functor ((<&>))
18-
import Data.Functor.Foldable (cata, Corecursive (embed))
18+
import Data.Functor.Foldable (Corecursive (embed), cata)
1919
import Data.List (intercalate, isPrefixOf, singleton, stripPrefix)
2020
import qualified Data.Map as Map
2121
import Data.Set (Set)
@@ -31,14 +31,13 @@ import Telomare
3131
import Telomare.Eval (compileUnitTestNoAbort)
3232
import Telomare.Parser (TelomareParser, parseAssignment, parseLongExpr,
3333
parsePrelude)
34+
import Telomare.Possible (evalPartial)
35+
import Telomare.PossibleData (DeferredEvalF (..), PartialExpr, deferredEE)
3436
import Telomare.Resolver (process)
3537
import Telomare.RunTime
3638
import Telomare.TypeChecker (inferType)
3739
import Text.Megaparsec
3840
import Text.Megaparsec.Char
39-
import Telomare.Possible (evalPartial)
40-
import Control.Monad.Identity (runIdentity, Identity)
41-
import Telomare.PossibleData (DeferredEvalF(..), deferredEE, PartialExpr)
4241

4342
-- Parsers for assignments/expressions within REPL
4443
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/PrettyPrint.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ module PrettyPrint where
66

77
import Control.Monad.State (State)
88
import Data.Map (Map)
9-
import Telomare (DataType (..), LamType (..), LocTag, PartExprF (..),
10-
StuckF (..), AbortableF (..), StuckExprF (..),
11-
CompiledExprF (..), Term3F (..), FunctionIndex,
12-
ParserTermF (..), PartialType (..), Pattern (..),
13-
Term1, Term3 (..),
14-
UnprocessedParsedTerm (..), UnprocessedParsedTermF (..),
15-
forget, indentWithChildren', convertAbortMessage,
16-
indentWithOneChild', indentWithTwoChildren', StuckExpr, pattern BasicEE, b2i, locatedNameText, CompiledExpr)
9+
import Telomare (AbortableF (..), CompiledExpr, CompiledExprF (..),
10+
DataType (..), FunctionIndex, LamType (..), LocTag,
11+
ParserTermF (..), PartExprF (..), PartialType (..),
12+
Pattern (..), StuckExpr, StuckExprF (..), StuckF (..), Term1,
13+
Term3 (..), Term3F (..), UnprocessedParsedTerm (..),
14+
UnprocessedParsedTermF (..), b2i, convertAbortMessage, forget,
15+
indentWithChildren', indentWithOneChild',
16+
indentWithTwoChildren', locatedNameText, pattern BasicEE)
1717

1818
import qualified Control.Comonad.Trans.Cofree as CofreeT (CofreeF (..))
1919
import qualified Control.Monad.State as State
@@ -296,7 +296,7 @@ instance Show PrettyStuckExpr where
296296
Just n -> show n
297297
_ -> case x of
298298
BasicEE (PairSF a b) -> "(" <> f a <> "," <> f b <> ")"
299-
z -> show z
299+
z -> show z
300300

301301
newtype PrettyCompiledExpr = PrettyCompiledExpr CompiledExpr
302302

@@ -307,4 +307,4 @@ instance Show PrettyCompiledExpr where
307307
Just n -> show n
308308
_ -> case x of
309309
BasicEE (PairSF a b) -> "(" <> f a <> "," <> f b <> ")"
310-
z -> show z
310+
z -> show z

src/Telomare.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE BangPatterns #-}
21
{-# LANGUAGE DeriveAnyClass #-}
32
{-# LANGUAGE DeriveGeneric #-}
43
{-# LANGUAGE DeriveTraversable #-}
@@ -246,7 +245,7 @@ instance Eq1 StuckExprF where
246245
liftEq test a b = case (a,b) of
247246
(StuckExprB x, StuckExprB y) -> liftEq test x y
248247
(StuckExprS x, StuckExprS y) -> liftEq test x y
249-
_ -> False
248+
_ -> False
250249
instance Show1 StuckExprF where
251250
liftShowsPrec showsPrec showList prec = \case
252251
StuckExprB x -> liftShowsPrec showsPrec showList prec x
@@ -848,7 +847,7 @@ convertAbortMessage = \case
848847
AbortRecursion t -> "recursion overflow (should be caught by other means) for rt: " <> show (b2i t)
849848
AbortUser s -> case b2s s of
850849
Nothing -> "user abort invalid data: " <> show s
851-
Just m -> "user abort: " <> m
850+
Just m -> "user abort: " <> m
852851
AbortAny -> "user abort of all possible abort reasons (non-deterministic input)"
853852
x -> "unexpected abort: " <> show x
854853

src/Telomare/Eval.hs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,31 @@ import System.IO
2525
import System.Process
2626

2727
import qualified Control.Comonad.Trans.Cofree as CofreeT
28+
import Control.Lens (Identity (runIdentity))
2829
import Data.Functor.Foldable (Base, cata, embed, para)
2930
import PrettyPrint
30-
import Telomare (AbstractRunTime, EvalError (..),
31-
LocTag (..), LocatedName (..),
32-
PartialType (..), Pattern,
33-
ResolverError (..),
34-
RunTimeError (..), TelomareLike (..), Term2,
35-
UnprocessedParsedTerm (..),
36-
UnprocessedParsedTermF (..), UnsizedRecursionToken (..),
37-
deferS, abortEE, locStartLineColumn,
38-
convertAbortMessage, eval, forget, embedB, basicEE, stuckEE, pairB, zeroB, rightB, leftB, embedS, setEnvB, envB, b2s, s2b,
39-
insertAndGetKey, appS, pattern ZeroB, pattern PairB,
40-
tag, Term3, CompiledExpr, StuckF (..), pattern StuckFW, Term3F (..), pattern AbortFW, StuckExpr, BasicExpr, CompiledExprF,
41-
PartExprF (..), pattern BasicEE, pattern StuckEE, convertBasic, convertStuck, convertAbort,
42-
pattern BasicFW, pattern StuckFW, Term3Builder, AbortableF (AbortF))
31+
import Telomare (AbortableF (AbortF), AbstractRunTime, BasicExpr, CompiledExpr,
32+
CompiledExprF, EvalError (..), LocTag (..), LocatedName (..),
33+
PartExprF (..), PartialType (..), Pattern, ResolverError (..),
34+
RunTimeError (..), StuckExpr, StuckF (..), TelomareLike (..),
35+
Term2, Term3, Term3Builder, Term3F (..),
36+
UnprocessedParsedTerm (..), UnprocessedParsedTermF (..),
37+
UnsizedRecursionToken (..), abortEE, appS, b2s, basicEE,
38+
convertAbort, convertAbortMessage, convertBasic, convertStuck,
39+
deferS, embedB, embedS, envB, eval, forget, insertAndGetKey,
40+
leftB, locStartLineColumn, pairB, pattern AbortFW,
41+
pattern BasicEE, pattern BasicFW, pattern PairB,
42+
pattern StuckEE, pattern StuckFW, pattern ZeroB, rightB, s2b,
43+
setEnvB, stuckEE, tag, zeroB)
4344
import Telomare.Parser (AnnotatedUPT, parseModule, parseOneExprOrTopLevelDefs,
4445
parsePrelude)
45-
import Telomare.Possible (SizingSettings (SizingSettings),
46-
appB, deferB, evalStaticCheck, basicEval,
47-
getSizesM, sizeTermM, term3ToUnsizedExpr,
48-
)
49-
import Telomare.PossibleData (SizedRecursion (..),
50-
VoidF,
51-
)
46+
import Telomare.Possible (SizingSettings (SizingSettings), appB, basicEval,
47+
deferB, evalStaticCheck, getSizesM, sizeTermM,
48+
term3ToUnsizedExpr)
49+
import Telomare.PossibleData (SizedRecursion (..), VoidF)
5250
import Telomare.Resolver (main2Term3, main2Term3let, process, resolveAllImports)
5351
import Telomare.TypeChecker (typeCheck)
5452
import Text.Megaparsec (errorBundlePretty, runParser)
55-
import Control.Lens (Identity(runIdentity))
5653

5754
debug :: Bool
5855
debug = False

src/Telomare/Possible.hs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,29 @@ import Debug
5454
import Debug.Trace
5555
import GHC.Generics (Generic)
5656
import PrettyPrint
57-
import Telomare (AbstractRunTime (..),
58-
LocTag (..), PartialType (..),
59-
RunTimeError (..), TelomareLike (fromTelomare, toTelomare),
60-
Term3 (..), AbortableF (..), StuckF (..), PartExprF (..),
61-
Term3F (..),
62-
pattern StuckFW, pattern BasicFW, pattern AbortFW,
63-
pattern StuckEE, pattern BasicEE, pattern AbortEE,
64-
pattern GateSwitch, pattern FillFunction,
65-
StuckBase(..), BasicBase(..), AbortBase(..),
66-
UnsizedRecursionToken (UnsizedRecursionToken),
67-
convertAbortMessage, forget, FunctionIndex (..),
68-
indentWithChildren', indentWithOneChild, indentWithOneChild',
69-
indentWithTwoChildren, indentWithTwoChildren',
70-
pattern AbortAny, pattern AbortRecursion,
57+
import Telomare (AbortBase (..), AbortableF (..), AbstractRunTime (..),
58+
BasicBase (..), BasicExpr, CompiledExpr, FunctionIndex (..),
59+
LocTag (..), PartExprF (..), PartialType (..),
60+
RunTimeError (..), StuckBase (..), StuckExpr, StuckExprF,
61+
StuckF (..), TelomareLike (fromTelomare, toTelomare),
62+
Term3 (..), Term3F (..),
63+
UnsizedRecursionToken (UnsizedRecursionToken), abortAny,
64+
abortEE, abortRecursion, abortUnsizeable, abortUser, b2i,
65+
basicEE, convertAbort, convertAbortMessage, convertBasic,
66+
convertStuck, envB, fillFunction, forget, gateB, gateSwitch,
67+
i2B, indentWithChildren', indentWithOneChild,
68+
indentWithOneChild', indentWithTwoChildren,
69+
indentWithTwoChildren', leftB, pairB, pattern AbortAny,
70+
pattern AbortEE, pattern AbortFW, pattern AbortRecursion,
7171
pattern AbortUnsizeable, pattern AbortUser, pattern AppEE,
72-
sindent, toPartialType, CompiledExpr, envB, StuckExpr, abortAny, zeroB, abortEE, pairB, basicEE, abortRecursion, i2B, stuckEE, leftB, rightB, fillFunction, setEnvB, gateB, gateSwitch, convertBasic, convertStuck, convertAbort, abortUnsizeable, b2i, abortUser, s2b, StuckExprF, BasicExpr)
72+
pattern BasicEE, pattern BasicFW, pattern FillFunction,
73+
pattern GateSwitch, pattern StuckEE, pattern StuckFW, rightB,
74+
s2b, setEnvB, sindent, stuckEE, toPartialType, zeroB)
7375
import Telomare.PossibleData
7476
-- import Telomare.RunTime (hvmEval)
77+
import Data.Functor.Identity (Identity (Identity), runIdentity)
7578
import Test.QuickCheck (Arbitrary (..), Gen, oneof)
7679
import Test.QuickCheck.Gen (sized)
77-
import Data.Functor.Identity (runIdentity, Identity (Identity))
7880

7981
debug :: Bool
8082
debug = False

src/Telomare/PossibleData.hs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
{-# LANGUAGE DeriveGeneric #-}
2-
{-# LANGUAGE DeriveTraversable #-}
3-
{-# LANGUAGE FlexibleInstances #-}
4-
{-# LANGUAGE LambdaCase #-}
5-
{-# LANGUAGE PatternSynonyms #-}
6-
{-# LANGUAGE TypeFamilies #-}
7-
{-# LANGUAGE ViewPatterns #-}
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE DeriveTraversable #-}
3+
{-# LANGUAGE FlexibleInstances #-}
4+
{-# LANGUAGE LambdaCase #-}
5+
{-# LANGUAGE PatternSynonyms #-}
6+
{-# LANGUAGE TypeFamilies #-}
7+
{-# LANGUAGE ViewPatterns #-}
88

99
module Telomare.PossibleData where
1010

@@ -27,12 +27,12 @@ import GHC.Generics (Generic)
2727

2828
import Data.Bifunctor (first)
2929
import PrettyPrint
30-
import Telomare (LocTag (..), PartialType (..), TelomareLike (..), FunctionIndex,
31-
UnsizedRecursionToken (..), convertAbortMessage,
32-
indentWithChildren', indentWithOneChild',
33-
indentWithTwoChildren', PartExprF (..), StuckF (..), AbortableF (..),
34-
BasicBase(..), StuckBase(..), AbortBase(..), CompiledExpr, convertBasic, convertStuck
35-
)
30+
import Telomare (AbortBase (..), AbortableF (..), BasicBase (..), CompiledExpr,
31+
FunctionIndex, LocTag (..), PartExprF (..), PartialType (..),
32+
StuckBase (..), StuckF (..), TelomareLike (..),
33+
UnsizedRecursionToken (..), convertAbortMessage, convertBasic,
34+
convertStuck, indentWithChildren', indentWithOneChild',
35+
indentWithTwoChildren')
3636

3737
debug' :: Bool
3838
debug' = False

src/Telomare/RunTime.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{-# LANGUAGE FlexibleContexts #-}
2-
{-# LANGUAGE LambdaCase #-}
2+
{-# LANGUAGE FlexibleInstances #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
4-
{-# LANGUAGE FlexibleInstances #-}
5-
{-# LANGUAGE PatternSynonyms #-}
64

75
module Telomare.RunTime where
86

@@ -18,13 +16,14 @@ import Data.Set (Set)
1816
import qualified Data.Set as Set
1917
import Debug.Trace
2018
import GHC.Exts (fromList)
19+
import PrettyPrint (prettyPrint)
2120
import System.IO (hGetContents)
2221
import System.Process (CreateProcess (std_out), StdStream (CreatePipe),
2322
createProcess, shell)
2423
import Telomare
24+
import Telomare.Possible (PPOut (..), basicStep, stuckStepDebug,
25+
transformNoDefer)
2526
import Text.Read (readMaybe)
26-
import Telomare.Possible (transformNoDefer, PPOut (..), basicStep, stuckStepDebug)
27-
import PrettyPrint (prettyPrint)
2827

2928
debug :: Bool
3029
debug = False

src/Telomare/TypeChecker.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE LambdaCase #-}
1+
{-# LANGUAGE LambdaCase #-}
22
{-# LANGUAGE PatternSynonyms #-}
33

44
module Telomare.TypeChecker where
@@ -15,14 +15,15 @@ import Data.Foldable (fold)
1515
import Data.Functor.Foldable
1616
import Data.Map (Map)
1717
import qualified Data.Map as Map
18+
import Data.Semigroup (Max (..))
1819
import Data.Set (Set)
1920
import qualified Data.Set as Set
2021
import Debug.Trace
2122
import PrettyPrint
22-
import Telomare (FunctionIndex (FunctionIndex), LocTag (..), PartialType (..),
23-
PartExprF (..), StuckF (..), AbortableF (..), Term3, Term3F (..), TypeCheckError (..),
24-
pattern StuckFW, pattern BasicFW, pattern AbortFW, pattern ZeroB, pattern PairB)
25-
import Data.Semigroup (Max(..))
23+
import Telomare (AbortableF (..), FunctionIndex (FunctionIndex), LocTag (..),
24+
PartExprF (..), PartialType (..), StuckF (..), Term3,
25+
Term3F (..), TypeCheckError (..), pattern AbortFW,
26+
pattern BasicFW, pattern PairB, pattern StuckFW, pattern ZeroB)
2627

2728
debug :: Bool
2829
debug = False

test/ResolverTests.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ showAllTransformations input = do
586586
stepIEval :: StuckExpr -> IO StuckExpr
587587
stepIEval x = case eval (fromTelomare x :: CompiledExpr) of
588588
Right r -> case toTelomare r of
589-
Just s -> pure s
589+
Just s -> pure s
590590
Nothing -> error "stepIEval: conversion failure"
591591
Left e -> error $ "stepIEval: " <> show e
592592

0 commit comments

Comments
 (0)