From d139f68bb517f9376ae9258b008d31a133b3b906 Mon Sep 17 00:00:00 2001 From: Roman Leshchinskiy Date: Fri, 7 Mar 2008 05:08:59 +0000 Subject: [PATCH] Fix vectorisation monad --- compiler/vectorise/VectMonad.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/vectorise/VectMonad.hs b/compiler/vectorise/VectMonad.hs index 836a020..b47da65 100644 --- a/compiler/vectorise/VectMonad.hs +++ b/compiler/vectorise/VectMonad.hs @@ -228,10 +228,12 @@ orElseV :: VM a -> VM a -> VM a orElseV p q = maybe q return =<< tryV p fixV :: (a -> VM a) -> VM a -fixV f = VM $ \bi genv lenv -> fixDs $ - \r -> case r of - Yes _ _ x -> runVM (f x) bi genv lenv - No -> return No +fixV f = VM (\bi genv lenv -> fixDs $ \r -> runVM (f (unYes r)) bi genv lenv ) + where + -- NOTE: It is essential that we are lazy in r above so do not replace + -- calls to this function by an explicit case. + unYes (Yes _ _ x) = x + unYes No = panic "VectMonad.fixV: no result" localV :: VM a -> VM a localV p = do -- 1.7.10.4