Type signature in a where clause

前端 未结 2 1995
青春惊慌失措
青春惊慌失措 2020-12-17 16:00

I\'ve written a function similar to Data.Enumerator.List.map that makes an Iteratee compatible with an Enumerator that feeds a differe

2条回答
  •  清歌不尽
    2020-12-17 16:24

    You probably want that type, but with the ScopedTypeVariables extension enabled and with the variables from test's type signature in scope:

    {-# LANGUAGE ScopedTypeVariables #-}
    import Data.Enumerator
    test :: forall m ai ao b. Monad m => (ao -> ai) -> Iteratee ai m b -> Iteratee ao m b
    test f iter = go $$ iter
       where go :: Step ai m b -> Iteratee ao m b
             go (Continue k) = continue $
                \stream -> go $$ k (fmap f stream)
             go (Yield res _) = yield res EOF
    

    See the GHC documentation for more information.

提交回复
热议问题