on master help sign in
39 lines 957 B history raw
1-- |
2-- Module : Streamly.Internal.Data.Stream.Step
3-- Copyright : (c) 2018 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
7-- Portability : GHC
9module Streamly.Internal.Data.Stream.Step
10 (
11 -- * The stream type
12 Step (..)
13 )
14where
16import Fusion.Plugin.Types (Fuse(..))
18-- | A stream is a succession of 'Step's. A 'Yield' produces a single value and
19-- the next state of the stream. 'Stop' indicates there are no more values in
20-- the stream.
21{-# ANN type Step Fuse #-}
22data Step s a = Yield a s | Skip s | Stop
24instance Functor (Step s) where
25 {-# INLINE fmap #-}
26 fmap f (Yield x s) = Yield (f x) s
27 fmap _ (Skip s) = Skip s
28 fmap _ Stop = Stop
30{-
31fromPure :: Monad m => a -> s -> m (Step s a)
32fromPure a = return . Yield a
34skip :: Monad m => s -> m (Step s a)
35skip = return . Skip
37stop :: Monad m => m (Step s a)
38stop = return Stop
39-}