On Sun, Oct 9, 2011 at 7:57 PM, Captain Freako <capn.freako@gmail.com> wrote:
21 applyFilter :: Filter e a -> FilterState -> a -> (Either e a, FilterState)
22 applyFilter f s x = runState (runEitherT (runFilter f)) s
I still don't understand how I'm supposed to feed the input, `x', into the filter.
In 'Filter e a', a is an output type, not an input type. If you want inputs, you'll need constructors of the form (a -> Filter e b).
This might be closer to what you're looking for:
applyFilter :: FilterState -> (a -> Filter e b) -> a -> (Either e b, FilterState)
applyFilter s f x = runState (runEitherT (runFilter (f x))) s
The burden of receiving input is then shifted to the functions that create 'Filter' operations.
If you really want the input type to be part of the Filter type definition, you'll need to use arrows instead of monads.