[Haskell-cafe] How to present the commonness of some objects?
Magicloud Magiclouds
magicloud.magiclouds at gmail.com
Fri Jul 3 00:00:05 EDT 2009
Hi,
I thought "class" was for this purpose. But it turns out not.
Code as following could not compiled.
1 main = do
2 mapM_ (\(x, y, widget) -> do
3 a <- widgetRun widget
4 putStrLn $ show a
5 ) widgetList
6
7 widgetList :: (Widget w) => [(Integer, Integer, w)]
8 widgetList = []
9
10 class Widget w where
11 widgetRun :: w -> IO ()
---
% ghc --make tmp/test.hs
[1 of 1] Compiling Main ( tmp/test.hs, /tmp/Main.o )
tmp/test.hs:3:16:
Ambiguous type variable `t' in the constraint:
`Widget t' arising from a use of `widgetRun' at tmp/test.hs:3:16-31
Probable fix: add a type signature that fixes these type variable(s)
--
竹密岂妨流水过
山高哪阻野云飞
More information about the Haskell-Cafe
mailing list