[Haskell-cafe] wondering about a MonadIO instance for a heap data type
qiqi789 at gmail.com
Thu Jul 12 02:00:25 CEST 2012
List  is a monad, why not for heap data. Heap data could be an instance
of Monad too.
I have the heapsort function, and just wanted to rewrite a verbose version
of it by using liftIO.
But I would look into Debug.Trace. Thanks for your hint.
On Wednesday, July 11, 2012 5:28:17 PM UTC-5, Eugene Kirpichov wrote:
> Use Debug.Trace.
> It does not make sense to declare that heap is a monad, as a monad is an
> abstraction of sequencing computations, and a heap is not an abstraction of
> sequencing computations at all. You don't make your String class implement
> the "rendering engine" interface just because you want to use it in a
> computer game program, equally you dont pretend that a heap is a way of
> sequencing computations just because you want to sequence computations
> related to heaps.
> The actual computation in your case is the heapsort function, not the
> heap. If you absolutely must use IO, add IO to the functions type.
> 11.07.2012, в 15:19, Qi Qi <qiqi789 at gmail.com> написал(а):
> > Hi,
> > I was wondering about creating an instance of MonadIO for a heap data.
> > Any hints?
> > data Heap a = E | T Int a (Heap a) (Heap a)
> > deriving (Eq, Ord, Read, Show)
> > The reason is that I want to use liftIO during a heapsort to print out
> > intermediate results.
> > Thanks.
> > Qi Qi
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe