Hi David,

Thanks for the reply.

In trying to follow your advice, I arrived at this code:

 17 newtype Filter e a = F {
 18     runFilter :: EitherT e (State FilterState) a
 19   } deriving (Monad, MonadState FilterState)
 20
 21 applyFilter :: Filter e a -> FilterState -> a -> (Either e a,
FilterState)
 22 applyFilter f s x  = runState (runEitherT (runFilter f)) s

which compiles ok, but I don't know where to put the `x' on the right side
of the `=' in line 22. That is, I still don't understand how I'm supposed to
feed the input, `x', into the filter.

Thanks,
-db


On Sat, Oct 8, 2011 at 5:27 PM, David Barbour <dmbarb...@gmail.com> wrote:

>
>
> On Sat, Oct 8, 2011 at 4:28 PM, Captain Freako <capn.fre...@gmail.com>wrote:
>
>>
>>  17 newtype Filter e a = F {
>> *  18     runFilter :: EitherT e (State FilterState) a
>> ** * 19   } deriving (Monad, MonadState FilterState)
>>
>> it compiles, but I can't figure out how I'd feed the input to the filter,
>> in that case.
>>
>
> Input to Filter would be modeled with:  'a -> Filter e b'.
>
> I would rename your 'runFilter' to 'unFilter', then define a function
> 'runFilter' accepting an initial FilterState.
>
> Regards,
>
> - db
>
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to