2013-03-28 62 views
2

如何在Haskell中不能创建16元组,这个错误是什么意思?尝试在Haskell中创建16元组时出现奇怪的错误

GHCi, version 7.6.2: http://www.haskell.org/ghc/ :? for help 
Loading package ghc-prim ... linking ... done. 
Loading package integer-gmp ... linking ... done. 
Loading package base ... linking ... done. 
Prelude> (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) 

<interactive>:2:1: 
    No instance for (Show 
         (t0, 
         t1, 
         t2, 
         t3, 
         t4, 
         t5, 
         t6, 
         t7, 
         t8, 
         t9, 
         t10, 
         t11, 
         t12, 
         t13, 
         t14, 
         t15)) 
     arising from a use of `print' 
    Possible fix: 
     add an instance declaration for 
     (Show 
     (t0, 
      t1, 
      t2, 
      t3, 
      t4, 
      t5, 
      t6, 
      t7, 
      t8, 
      t9, 
      t10, 
      t11, 
      t12, 
      t13, 
      t14, 
      t15)) 
    In a stmt of an interactive GHCi command: print it 

<interactive>:2:2: 
    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 expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:4: 
    No instance for (Num t1) arising from the literal `2' 
    The type variable `t1' 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: 2 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:6: 
    No instance for (Num t2) arising from the literal `3' 
    The type variable `t2' 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: 3 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:8: 
    No instance for (Num t3) arising from the literal `4' 
    The type variable `t3' 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: 4 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:10: 
    No instance for (Num t4) arising from the literal `5' 
    The type variable `t4' 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: 5 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:12: 
    No instance for (Num t5) arising from the literal `6' 
    The type variable `t5' 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: 6 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:14: 
    No instance for (Num t6) arising from the literal `7' 
    The type variable `t6' 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: 7 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:16: 
    No instance for (Num t7) arising from the literal `8' 
    The type variable `t7' 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: 8 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:18: 
    No instance for (Num t8) arising from the literal `9' 
    The type variable `t8' 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: 9 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:20: 
    No instance for (Num t9) arising from the literal `10' 
    The type variable `t9' 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: 10 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:23: 
    No instance for (Num t10) arising from the literal `11' 
    The type variable `t10' 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: 11 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:26: 
    No instance for (Num t11) arising from the literal `12' 
    The type variable `t11' 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: 12 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:29: 
    No instance for (Num t12) arising from the literal `13' 
    The type variable `t12' 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: 13 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:32: 
    No instance for (Num t13) arising from the literal `14' 
    The type variable `t13' 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: 14 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:35: 
    No instance for (Num t14) arising from the literal `15' 
    The type variable `t14' 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: 15 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 

<interactive>:2:38: 
    No instance for (Num t15) arising from the literal `16' 
    The type variable `t15' 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: 16 
    In the expression: 
     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
    In an equation for `it': 
     it = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) 
Prelude> 
+0

类似的问题在这里问:http://stackoverflow.com/questions/15559234/working-with-list-of-tuples-in-haskell/15559825 – kputnam

+0

重复的http://stackoverflow.com/q/2978389/ 676939 – Alexandros

+0

@Alexandros:这不是重复的,我在问16个错误是什么意思,这个“答案”在这里没有回答。 – Dog

回答

13

基础libary仅包括元组展情况下可达15大小一般是不使用非常大的元组是个好主意。

+0

好的,但问题的后半部分仍未得到答复。 – Dog

+2

1)你可以在Haskell中制作16个元组(你刚刚做过),2)错误意味着在Prelude中没有将16元组转换为字符串的例程,但是你可以随意创建自己的'instance Show .. .'。 –

+0

@ ThomasM.DuBuisson但是为什么在那之后还有16个错误呢? – Dog

相关问题