2014-02-25 70 views
0

我的代碼接收一個十六進制值的列表,我必須將它們傳遞給二進制,並將每個結果放在一個列表中,但我有這兩個錯誤,我不知道如何解決它們我不明白這個錯誤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 = "*" 
+0

你可以給出最小的可編譯示例,像素和ord缺失 – jozefg

+1

你有沒有試過指定modA的類型簽名。這通常會導致更容易理解的錯誤消息。 – user1937198

回答

6

你的語法是錯誤的,你需要一個|otherwise

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