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

Commit 0564b9d

Browse files
author
Patrick Thomson
committed
Eliminate mtl dependency.
1 parent 2cefe29 commit 0564b9d

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

semantic.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ common dependencies
6767
, streaming ^>= 0.2.2.0
6868
, text ^>= 1.2.3.1
6969
, these >= 0.7 && <1
70+
, transformers ^>= 0.5.6.2
7071
, unix ^>= 2.7.2.2
7172
, proto3-suite
7273
, proto3-wire

src/Reprinting/Translate.hs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import Control.Effect
99
import Control.Effect.Error
1010
import Control.Effect.State
1111
import Control.Monad
12-
import Control.Monad.Trans
1312
import Streaming
14-
import Streaming.Prelude (yield)
1513
import qualified Streaming.Prelude as Streaming
1614

1715
import Data.Reprinting.Errors
@@ -26,14 +24,14 @@ type TranslatorC
2624

2725
contextualizing :: Stream (Of Token) TranslatorC a
2826
-> Stream (Of Fragment) TranslatorC a
29-
contextualizing s = Streaming.for s $ \case
30-
Chunk source -> yield . Verbatim . Source.toText $ source
31-
Element t -> case t of
32-
Run f -> lift get >>= \c -> yield (New t c f)
33-
_ -> lift get >>= yield . Defer t
34-
Control ctl -> case ctl of
35-
Enter c -> lift (enterScope c)
36-
Exit c -> lift (exitScope c)
27+
contextualizing = Streaming.mapMaybeM $ \case
28+
Chunk source -> pure . Just . Verbatim . Source.toText $ source
29+
Element t -> Just <$> case t of
30+
Run f -> get >>= \c -> pure (New t c f)
31+
_ -> get >>= pure . Defer t
32+
Control ctl -> Nothing <$ case ctl of
33+
Enter c -> enterScope c
34+
Exit c -> exitScope c
3735
_ -> pure ()
3836

3937
enterScope :: (Member (State [Scope]) sig, Carrier sig m)

src/Tags/Tagging.hs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import Prologue hiding (Element, hash)
1010

1111
import Control.Effect as Eff
1212
import Control.Effect.State
13-
import Control.Monad.Trans
1413
import Data.Text as T hiding (empty)
1514
import Streaming
16-
import Streaming.Prelude (yield)
1715
import qualified Streaming.Prelude as Streaming
1816

1917
import Data.Blob
@@ -37,23 +35,22 @@ runTagging blob symbolsToSummarize
3735

3836
type ContextToken = (Text, Maybe Range)
3937

40-
-- PT TODO: fix me as well
4138
contextualizing :: ( Member (State [ContextToken]) sig
4239
, Carrier sig m
4340
)
4441
=> Blob
4542
-> [Text]
4643
-> Stream (Of Token) m a
4744
-> Stream (Of Tag) m a
48-
contextualizing Blob{..} symbolsToSummarize s = Streaming.for s $ \case
49-
Enter x r -> lift (enterScope (x, r))
50-
Exit x r -> lift (exitScope (x, r))
51-
Iden iden span docsLiteralRange -> lift (get @[ContextToken]) >>= \case
45+
contextualizing Blob{..} symbolsToSummarize = Streaming.mapMaybeM $ \case
46+
Enter x r -> Nothing <$ enterScope (x, r)
47+
Exit x r -> Nothing <$ exitScope (x, r)
48+
Iden iden span docsLiteralRange -> get @[ContextToken] >>= pure . \case
5249
((x, r):("Context", cr):xs) | x `elem` symbolsToSummarize
53-
-> yield $ Tag iden x span (fmap fst xs) (firstLine (slice r)) (slice cr)
50+
-> Just $ Tag iden x span (fmap fst xs) (firstLine (slice r)) (slice cr)
5451
((x, r):xs) | x `elem` symbolsToSummarize
55-
-> yield $ Tag iden x span (fmap fst xs) (firstLine (slice r)) (slice docsLiteralRange)
56-
_ -> pure ()
52+
-> Just $ Tag iden x span (fmap fst xs) (firstLine (slice r)) (slice docsLiteralRange)
53+
_ -> Nothing
5754
where
5855
slice = fmap (stripEnd . Source.toText . flip Source.slice blobSource)
5956
firstLine = fmap (T.take 180 . fst . breakOn "\n")

0 commit comments

Comments
 (0)