[Haskell-cafe] How to present the commonness of some objects?
magicloud.magiclouds at gmail.com
Fri Jul 3 00:00:05 EDT 2009
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
7 widgetList :: (Widget w) => [(Integer, Integer, w)]
8 widgetList = 
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 )
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