suztomoの日記

To be a good software engineer

"last" as iteratee

last

last :: IterV el (Maybe el)
last = Cont (step Nothing)
  where
    step :: (Maybe el) -> (StreamG el -> IterV el (Maybe el))
    step _ (El el) = Cont (step (Just el))
    step prev Empty = Cont (step prev)
    step prev EOF = Done prev EOF