@@ -95,7 +95,8 @@ stages of the pipeline follows:
9595
9696-}
9797
98- {-# LANGUAGE AllowAmbiguousTypes, ScopedTypeVariables, RankNTypes #-}
98+ {-# LANGUAGE AllowAmbiguousTypes, PartialTypeSignatures, RankNTypes, ScopedTypeVariables #-}
99+ {-# OPTIONS_GHC -Wno-partial-type-signatures #-}
99100module Reprinting.Pipeline
100101 ( runReprinter
101102 , runTokenizing
@@ -106,10 +107,10 @@ module Reprinting.Pipeline
106107import Control.Effect as Effect
107108import Control.Effect.Error as Effect
108109import Control.Effect.State as Effect
109- import Data.Machine hiding (Source )
110- import Data.Machine.Runner
111110import Data.Text.Prettyprint.Doc
112111import Data.Text.Prettyprint.Doc.Render.Text
112+ import Streaming
113+ import qualified Streaming.Prelude as Streaming
113114
114115import Data.Reprinting.Errors
115116import Data.Reprinting.Scope
@@ -121,57 +122,58 @@ import Reprinting.Tokenize
121122import Reprinting.Translate
122123import Reprinting.Typeset
123124
124-
125- -- | Run the reprinting pipeline given the original 'Source', a language
126- -- specific machine (`ProcessT`) and the provided 'Term'.
125+ -- | Run the reprinting pipeline given the original 'Source', a language specific
126+ -- translation function (as a function over 'Stream's) and the provided 'Term'.
127127runReprinter :: Tokenize a
128- => Source. Source
129- -> ProcessT Translator Fragment Splice
130- -> Term a History
131- -> Either TranslationError Source. Source
132- runReprinter src translating tree
128+ => Source. Source
129+ -> ( Stream ( Of Fragment ) _ () -> Stream ( Of Splice ) _ () )
130+ -> Term a History
131+ -> Either TranslationError Source. Source
132+ runReprinter src translating
133133 = fmap go
134134 . Effect. run
135135 . Effect. runError
136- . fmap snd
137- . runState ( mempty :: [ Scope ])
138- . foldT $ source (tokenizing src tree)
139- ~> contextualizing
140- ~> translating
141- ~> typesetting
136+ . evalState @ [ Scope ] mempty
137+ . Streaming. mconcat_
138+ . typesetting
139+ . translating
140+ . contextualizing
141+ . tokenizing src
142142 where go = Source. fromText . renderStrict . layoutPretty defaultLayoutOptions
143143
144144-- | Run the reprinting pipeline up to tokenizing.
145145runTokenizing :: Tokenize a
146- => Source. Source
147- -> Term a History
148- -> [Token ]
149- runTokenizing src tree
150- = Data.Machine. run $ source (tokenizing src tree)
146+ => Source. Source
147+ -> Term a History
148+ -> [Token ]
149+ runTokenizing src
150+ = runIdentity
151+ . Streaming. toList_
152+ . tokenizing src
151153
152154-- | Run the reprinting pipeline up to contextualizing.
153155runContextualizing :: Tokenize a
154156 => Source. Source
155157 -> Term a History
156158 -> Either TranslationError [Fragment ]
157- runContextualizing src tree
159+ runContextualizing src
158160 = Effect. run
159161 . Effect. runError
160- . fmap snd
161- . runState ( mempty :: [ Scope ])
162- . runT $ source (tokenizing src tree)
163- ~> contextualizing
162+ . evalState @ [ Scope ] mempty
163+ . Streaming. toList_
164+ . contextualizing
165+ . tokenizing src
164166
165167runTranslating :: Tokenize a
166168 => Source. Source
167- -> ProcessT Translator Fragment Splice
169+ -> ( Stream ( Of Fragment ) _ () -> Stream ( Of Splice ) _ () )
168170 -> Term a History
169171 -> Either TranslationError [Splice ]
170- runTranslating src translating tree
172+ runTranslating src translating
171173 = Effect. run
172174 . Effect. runError
173- . fmap snd
174- . runState ( mempty :: [ Scope ])
175- . runT $ source (tokenizing src tree)
176- ~> contextualizing
177- ~> translating
175+ . evalState @ [ Scope ] mempty
176+ . Streaming. toList_
177+ . translating
178+ . contextualizing
179+ . tokenizing src
0 commit comments