我有一个Map (Int,Int) Char
,我正在尝试将其中的每个Char
s 绘制在键中包含的位置。我的职能是:
import qualified Data.Map.Strict as SM
data Position = Position !GLint !GLint
drawMirrors :: SM.Map (Int,Int) Char -> IO()
drawMirrors mirrors = do
mapM_ (\(x,y) c -> drawMirror c (Position x y)) mirrors
drawMirror :: Char -> Position -> IO()
drawMirror orientation (Position x y) = do
-- Some irrelevant stuff
在线drawMirrors mirrors = do mapM_ (\(x,y) c -> drawMirror c (Position x y)) mirrors
上,我收到错误消息:
src\Main.hs:200:33: Couldn't match expected type `Char -> IO ()' with actual type `IO b0' The lambda expression `\ (x, y) c -> drawMirror c (Position y)' has two arguments, but its type `(t0, GLint) -> IO b0' has only one In the first argument of `mapM_', namely `(\ (x, y) c -> drawMirror c (Position y))' In a stmt of a 'do' block: mapM_ (\ (x, y) c -> drawMirror c (Position y)) mirrors
如何在drawMirrors
中获取字典中的所有键和值并drawMirror
使用这些键和值应用函数?