You are suggesting later in this thread that the old ListT could be used
to solve my initial problem.  I don't see how, so I'm wondering if you'd
mind sorting some things out for me?

On Tue, Jan 23, 2007 at 11:59:58 +0200, Yitzchak Gale wrote:
[..]
>test = do
> a <- liftIO getChar
> guard $ a /= 'q'
> return $ a `mplus` test

This piece has type problems.  I couldn't get ghci to accept it without
making some changes:

  test :: ListT IO Char
  test = do
      a <- liftIO getChar
      guard $ a /= 'q'
      (return a) `mplus` test

[..]
>test2 = runListT . mapM (liftIO print)

There are some type problems here too, and I don't really see how to fix
them.

  > :t liftIO
  liftIO :: (MonadIO m) => IO a -> m a
  > :t print
  print :: (Show a) => a -> IO ()
  > :t (liftIO print)
      Couldn't match expected type `IO a'
             against inferred type `a1 -> IO ()'
      In the first argument of `liftIO', namely `print'

I also don't quite see how 'mapM foo` can be applied to a ListT since
'mapM foo' would have the type [a] -> m [b] (a & b depending on foo).
Perhaps you didn't mean mapM but rather mapListT?
But using mapListT in a similar way:

  > runListT.mapListT (\ m -> m >>= mapM putChar) $ test

does not result in the desired interleaving.  Changing to using runListT
first also gives the wrong behaviour:

  > runListT test >>= mapM_ putChar

I am really confused about your statement that ListT as found in GHC 6.6
can be used to solve my problem.  I'd like to avoid using
unsafeInterleaveIO if there's a nice solution for it.  IMHO a solution
with ListT would be nice, so I'd really like to understand how to make
it work the way I want it.

/M

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
[EMAIL PROTECTED]             Jabber: [EMAIL PROTECTED]
http://therning.org/magnus

Attachment: pgp8hV5I4iCJ8.pgp
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to