[Haskell-cafe] About the return type

xu zhang douyaxu at gmail.com
Thu Jul 9 10:57:19 EDT 2009


I have trouble in returning a list of Figures. I want return a type of m
(Maybe [Figure IO]), but the type of dv_findFigure is :: a -> Point -> s
(Maybe (Figure s)). How can change the code below to get a s (Maybe [Figure
s])?
Thank you in advance!

 dv_findFigure :: a -> Point -> s (Maybe (Figures))
 fig_contains :: fig -> Point -> m Bool
 anc :: Point
do
                     fs <- dv_getSelFigs dv
                     fs' <- filterM (`fig_contains` anc) fs
                     f <- case fs' of
                        [] -> dv_findFigure dv anc
                        fig : _ -> return $ Just fig
                     case f of
                       Just f' -> tool_dragtrack self f'
                       Nothing -> dv_clearSel dv >> tool_areatrack self

  Couldn't match expected type `Figure m'
           against inferred type `[Figure IO]'
      Expected type: m (Maybe (Figure m))
      Inferred type: m (Maybe [Figure IO])
    In the expression: return $ Just fs
    In a case alternative: fig : _ -> return $ Just fs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090709/b16a7041/attachment.html


More information about the Haskell-Cafe mailing list