bkerby

Untitled

Jul 11th, 2012
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. Graph.hs:36:14:
  2. Couldn't match type `Int' with `Maybe Int'
  3. When using functional dependencies to combine
  4. Control.Monad.State.Class.MonadState s (StateT s m),
  5. arising from the dependency `m -> s'
  6. in the instance declaration in `Control.Monad.State.Class'
  7. Control.Monad.State.Class.MonadState
  8. (IM.IntMap (Maybe Int))
  9. (StateT
  10. (IM.IntMap Int)
  11. (Control.Monad.Trans.Reader.ReaderT
  12. (IM.IntMap (IM.IntMap Int)) Data.Functor.Identity.Identity)),
  13. arising from a use of `get' at Graph.hs:36:14-16
  14. In a stmt of a 'do' block: distance <- get
  15. In the expression:
  16. do { γ <- ask;
  17. distance <- get;
  18. let candidates :: [Vertex]
  19. candidates = ...
  20. ....;
  21. case newVertex of {
  22. Just (v, d) -> do { ... }
  23. Nothing -> return False } }
  24.  
  25.  
  26.  
  27. ---------------
  28. step ∷ StateT (IM.IntMap Distance) (Reader Graph) Bool
  29. step = do
  30. γ ← ask
  31. distance ← get --line 36
  32. let candidates ∷ [Vertex]
  33. candidates = concatMap nub . map (\v → (IM.keys $ γ IM.! v) \\ (IM.keys distance)) $ IM.keys distance ∷ [Vertex]
  34. nearestWay ∷ Vertex → Distance
  35. nearestWay c = minimum . catMaybes . map (\v → (+ distance IM.! v) `fmap` IM.lookup c $ γ IM.! v) $ IM.keys distance
  36. newVertex ∷ Maybe (Vertex, Distance)
  37. newVertex = listToMaybe . sortBy (compare `on` snd) . map (\c → (c, nearestWay c)) candidates
  38. case newVertex of
  39. Just (v, d) → do
  40. put $ IM.insert v d distance
  41. return True
  42. Nothing → return False
Advertisement
Add Comment
Please, Sign In to add comment