Bulat Ziganshin schrieb:
> may be this will be useful:
> 
> -- This "equalizer" routine required because MArray interface was changed in 
> GHC 6.6
> #if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ >= 605)
> getMBounds arr = getBounds arr
> #else
> getMBounds arr = return (bounds arr)
> #endif
> 
> usage example:
> 
> putMArrayWith write h arr    = do bounds <- getMBounds arr
>                                   loop 0 (rangeSize(bounds)-1)
>                                       (\i -> unsafeRead arr i >>= write h)
> 

Hi Bulat, thanks for your answer, but the code in LALR.lhs:626:34
(happy-1.15) lacks a monad for getBounds (or I'm blind):

> countConflicts :: ActionTable -> (Array Int (Int,Int), (Int,Int))
> countConflicts action
>   = (conflictArray, foldr (\(a,b) (c,d) -> (a+c, b+d)) (0,0) conflictList)
>
>   where
>
>       conflictArray = listArray (bounds action) conflictList ---- <<<<
>       conflictList  = map countConflictsState (assocs action)
>
>       countConflictsState (state, actions)
>         = foldr countMultiples (0,0) (elems actions)
>         where
>           countMultiples (LR'Multiple (_:_) (LR'Shift{})) (sr,rr)
>               = (sr + 1, rr)
>           countMultiples (LR'Multiple (_:_) (LR'Reduce{})) (sr,rr)
>               = (sr, rr + 1)
>           countMultiples (LR'Multiple as a) (sr,rr)
>               = error "bad conflict representation"
>           countMultiples _ c = c
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to