Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 9f20899

Browse files
author
Patrick Thomson
committed
Can't eliminate MTL yet, but we can minimize it.
1 parent 0564b9d commit 9f20899

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/Diffing/Algorithm/RWS.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Diffing.Algorithm.RWS
1414
, equalTerms
1515
) where
1616

17-
import Control.Monad.State.Strict
17+
import Control.Monad.Trans.State.Strict
1818
import Data.Diff (DiffF(..), deleting, inserting, merge, replacing)
1919
import qualified Data.KdMap.Static as KdMap
2020
import Data.List (sortOn)

src/Language/JSON/PrettyPrint.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ module Language.JSON.PrettyPrint
88

99
import Prologue
1010

11-
import Control.Effect
12-
import Control.Effect.Error
13-
import Control.Monad.Trans (lift)
14-
import Streaming
11+
import Control.Effect
12+
import Control.Effect.Error
13+
import Streaming
1514
import qualified Streaming.Prelude as Streaming
1615

1716
import Data.Reprinting.Errors
17+
import Data.Reprinting.Scope
1818
import Data.Reprinting.Splice
1919
import Data.Reprinting.Token
20-
import Data.Reprinting.Scope
2120

2221
-- | Default printing pipeline for JSON.
2322
defaultJSONPipeline :: (Member (Error TranslationError) sig, Carrier sig m)
@@ -35,9 +34,9 @@ printingJSON = Streaming.map step where
3534
step s@(Defer el cs) =
3635
let ins = New el cs
3736
in case (el, listToMaybe cs) of
38-
(Truth True, _) -> ins "true"
39-
(Truth False, _) -> ins "false"
40-
(Nullity, _) -> ins "null"
37+
(Truth True, _) -> ins "true"
38+
(Truth False, _) -> ins "false"
39+
(Nullity, _) -> ins "null"
4140

4241
(Open, Just List) -> ins "["
4342
(Close, Just List) -> ins "]"
@@ -48,7 +47,7 @@ printingJSON = Streaming.map step where
4847
(Sep, Just Pair) -> ins ":"
4948
(Sep, Just Hash) -> ins ","
5049

51-
_ -> s
50+
_ -> s
5251
step x = x
5352

5453
-- TODO: Fill out and implement configurable options like indentation count,
@@ -65,22 +64,22 @@ beautifyingJSON :: (Member (Error TranslationError) sig, Carrier sig m)
6564
-> Stream (Of Fragment) m a
6665
-> Stream (Of Splice) m a
6766
beautifyingJSON _ s = Streaming.for s step where
68-
step (Defer el cs) = lift (throwError (NoTranslation el cs))
67+
step (Defer el cs) = effect (throwError (NoTranslation el cs))
6968
step (Verbatim txt) = emit txt
7069
step (New el cs txt) = case (el, cs) of
7170
(Open, Hash:_) -> emit txt *> layout HardWrap *> indent 2 (hashDepth cs)
7271
(Close, Hash:rest) -> layout HardWrap *> indent 2 (hashDepth rest) *> emit txt
7372
(Sep, List:_) -> emit txt *> space
7473
(Sep, Pair:_) -> emit txt *> space
7574
(Sep, Hash:_) -> emit txt *> layout HardWrap *> indent 2 (hashDepth cs)
76-
_ -> emit txt
75+
_ -> emit txt
7776

7877
-- | Produce whitespace minimal JSON.
7978
minimizingJSON :: (Member (Error TranslationError) sig, Carrier sig m)
8079
=> Stream (Of Fragment) m a
8180
-> Stream (Of Splice) m a
8281
minimizingJSON s = Streaming.for s step where
83-
step (Defer el cs) = lift (throwError (NoTranslation el cs))
82+
step (Defer el cs) = effect (throwError (NoTranslation el cs))
8483
step (Verbatim txt) = emit txt
8584
step (New _ _ txt) = emit txt
8685

src/Language/Python/PrettyPrint.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module Language.Python.PrettyPrint ( printingPython ) where
44

55
import Control.Effect
66
import Control.Effect.Error
7-
import Control.Monad.Trans (lift)
87
import Streaming
98
import qualified Streaming.Prelude as Streaming
109

@@ -66,7 +65,7 @@ step (Defer el cs) = case (el, cs) of
6665
(Sep, Imperative:xs) -> layout HardWrap *> indent 4 (imperativeDepth xs)
6766
(Close, Imperative:_) -> pure ()
6867

69-
_ -> lift (throwError (NoTranslation el cs))
68+
_ -> effect (throwError (NoTranslation el cs))
7069

7170
where
7271
endContext times = layout HardWrap *> indent 4 (pred times)

src/Language/Ruby/PrettyPrint.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ step (Defer el cs) = case (el, cs) of
5252
(Close, [Imperative]) -> layout HardWrap
5353
(Close, Imperative:xs) -> indent 2 (pred (imperativeDepth xs))
5454

55-
(Sep, Call:_) -> emit "."
55+
(Sep, Call:_) -> emit "."
5656

57-
_ -> lift (throwError (NoTranslation el cs))
57+
_ -> effect (throwError (NoTranslation el cs))
5858

5959
where
6060
endContext times = layout HardWrap *> indent 2 (pred times)

0 commit comments

Comments
 (0)