我不明白这个错误haskell

时间:2014-02-25 21:01:40

标签: haskell

我的代码收到一个十六进制的值列表,我必须将它们传递给二进制文件并将每个结果放在一个列表中,但我有这两个错误,我不知道如何修复它们

Pixels.hs:121:29:
    Occurs check: cannot construct the infinite type:
      t0 = Bool -> [a1] -> t0
    In the return type of a call of `modA'
    Probable cause: `modA' is applied to too many arguments
    In the expression:
      modA (o ++ [(k `mod` 2)]) (l + 1) (k `div` 2) otherwise o
    In an equation for `modA':
        modA o l k
          | l < 8 = modA (o ++ [(k `mod` 2)]) (l + 1) (k `div` 2) otherwise o

Pixels.hs:126:89:
    Couldn't match expected type `[a0]'
                with actual type `Bool -> t1 -> [[a1]] -> [a0] -> t0'
    In the first argument of `(++)', namely `f'
    In the fourth argument of `f', namely
      `(f
        ++
          [(psr (head (e1)))
           ++
             (psr (head (e2)))
             ++ (psr (head (e3))) ++ (psr (head (e4))) ++ (psr (head (e5)))])'
    In the expression:
      f otherwise
        convertir
        [tail (e1), tail (e2), tail (e3), tail (e4), ....]
        (f
         ++
           [(psr (head (e1)))
            ++
              (psr (head (e2)))
              ++ (psr (head (e3))) ++ (psr (head (e4))) ++ (psr (head (e5)))])
Failed, modules loaded: none.

这是代码

rInt :: String -> Int
rInt = read


font:: Char -> Pixels
font a = let x= ord a in
        if x>=0 || x<=31 || x>=126 then ["*****","*****","*****","*****","*****","*****","*****"]
        else
            auxfont (fontBitmap!!(x-32))
            where
            auxfont b = let y = map trns (map rInt (map show b)) in
                       convertir y []

            trns z = modA [] 1 z
            modA o l k
                  | l < 8 = modA (o++[(k `mod` 2)]) (l+1) (k `div` 2) 
                  otherwise o           

            convertir (e1:e2:e3:e4:e5) f 
                    |  null e1  = f
                    otherwise convertir [tail(e1),tail(e2),tail(e3),tail(e4),tail(e5)] (f++[(psr(head(e1)))++(psr(head(e2)))++(psr(head(e3)))++(psr(head(e4)))++(psr(head(e5)))])
            psr 0 = " "
            psr 1 = "*"

1 个答案:

答案 0 :(得分:6)

您的语法错误,|之前需要otherwise

foo x y z | x > y = ...
          | otherwise = ...