On Tue, Nov 9, 2010 at 8:10 AM, C K Kashyap <[email protected]> wrote: ] I think I can restate my problem like this --- ] ] If I have a list of actions as follows - ] ] import Data.Word ] import Data.Binary.Get ] ] data MyAction = A1 (Get Word8) | A2 (Get Word16) ] ] a = A1 getWord8 ] b = A2 getWord16be ] ] listOfActions = [a,b,a] ] ] How can I execute the "listOfActions" inside of a Get Monad and get ] the output as a list?
Do you mean, something like this? > import Control.Applicative ((<$>)) > > data MyAction m = A1 (m Word8) | A2 (m Word16) > > a = A1 getWord8 > b = A2 getWord16be > > listOfActions = [a,b,a] > > newtype Id a = Id a > > getAction :: MyAction Get -> Get (MyAction Id) > getAction (A1 act) = A1 . Id <$> act > getAction (A2 act) = A2 . Id <$> act > > getActions :: [MyAction Get] -> Get [MyAction Id] > getActions = mapM getAction -- Felipe. _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
