@@ -10,10 +10,8 @@ import Prologue hiding (Element, hash)
1010
1111import Control.Effect as Eff
1212import Control.Effect.State
13- import Control.Monad.Trans
1413import Data.Text as T hiding (empty )
1514import Streaming
16- import Streaming.Prelude (yield )
1715import qualified Streaming.Prelude as Streaming
1816
1917import Data.Blob
@@ -37,23 +35,22 @@ runTagging blob symbolsToSummarize
3735
3836type ContextToken = (Text , Maybe Range )
3937
40- -- PT TODO: fix me as well
4138contextualizing :: ( 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