import Text.Printf
printf "the length of this list is %d" length' [1,2,3,4,5]
我这样做了,但是失败了。
'func.hs:38:58:
No instance for (Num t0) arising from the literal `1'
The type variable `t0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
In the expression: 1
In the third argument of `printf', namely `[1, 2, 3, 4, ....]'
In a stmt of a 'do' block:
printf "the length of this list is %d" length' [1, 2, 3, 4, ....]"