On Tue, Sep 20, 2005 at 04:30:25PM +0100, Neil Mitchell wrote:
> Take a look at unsafePerformIO, it is of type IO a -> a. Its not
> particularly "safe" (the name gives a clue), but it does what you
> want.
> I dont think you would ever need to do unsafePerformIO unless
you are writing some lib calls or some such thing
> > onMouse w streams isEditChecked mouse
> > = case mouse of
> > MouseLeftDown pt mods ->
> > if isEditChecked then
> > findStream w streams pt
> > else
> > addStream w streams pt
> > other -> skipCurrentEvent --
In your case the approach should be some thing along these lines
onMouse w streams isEditChecked mouse
= do
ischecked <- isEditChecked
case mouse of
if ischecked then
findStream w streams pt
...
I am assuming that findStream w streams pt is of type IO a for
some a. otherwise you might have to use something like
return $ findStream w streams pt
Also the function onMouse will return some IO something. Remember there is
no real reason to use unsafePerformIO unless you are writing some new
IO library call.
ppk