1-- We use fromStreamK/toStreamK to convert the direct style stream to CPS
2-- style. In the first phase we try fusing the fromStreamK/toStreamK using:
4-- {-# RULES "fromStreamK/toStreamK fusion"
5-- forall s. toStreamK (fromStreamK s) = s #-}
7-- If for some reason some of the operations could not be fused then we have
8-- fallback rules in the second phase. For example:
10-- {-# INLINE_EARLY unfoldr #-}
11-- unfoldr :: (Monad m, IsStream t) => (b -> Maybe (a, b)) -> b -> t m a
12-- unfoldr step seed = fromStreamD (S.unfoldr step seed)
13-- {-# RULES "unfoldr fallback to StreamK" [1]
14-- forall a b. S.toStreamK (S.unfoldr a b) = K.unfoldr a b #-}```
16-- Then, fromStreamK/toStreamK are inlined in the last phase:
18-- {-# INLINE_LATE toStreamK #-}
19-- toStreamK :: Monad m => Stream m a -> K.StreamK m a```
21-- The fallback rules make sure that if we could not fuse the direct style
22-- operations then better use the CPS style operation, because unfused direct
23-- style would have worse performance than the CPS style ops.
25#define INLINE_EARLY INLINE [2]
26#define INLINE_NORMAL INLINE [1]
27#define INLINE_LATE INLINE [0]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list