streamly
streamly copied to clipboard
Write init and tail as stream transformations
init :: Monad m => Stream m a -> Stream m a
tail :: Monad m => Stream m a -> Stream m a
As a stream transformation tail is just drop 1 except that tail errors out on empty srteam whereas drop does not.
We can generalize tail and init to drop and dropEnd. To imitate the tail and init behavior we may need dropExact and dropEndExact variants that error out if less than specified elements are dropped.
Also, once we have composable Scan type, we can write these as scans instead of stream specific implementations.