这个 haskell 代码有什么问题?

What can be the fault in this haskell code?

友情号码

areAmicableNumbers ::  Integral a => a -> a -> [Bool]

areAmicableNumbers x y = 
   [(sum [k | k <- [1..x], x `mod` k ==0]) == y]  
  && 
   [(sum [i | i <- [1..y], y `mod` i ==0]) == x]
Error: Homework1.hs:23:26: error:
    * Couldn't match expected type `Bool' with actual type `[Bool]'
    * In the first argument of `(&&)', namely
        `[(sum [k | k <- [1 .. x], x `mod` k == 0]) == y]'
      In the expression:
        [(sum [k | k <- [1 .. x], x `mod` k == 0]) == y]
          && [(sum [i | i <- [1 .. y], y `mod` i == 0]) == x]
      In an equation for `areAmicableNumbers':
          areAmicableNumbers x y
            = [(sum [k | k <- [1 .. x], x `mod` k == 0]) == y]
                && [(sum [i | i <- [1 .. y], y `mod` i == 0]) == x]
   |
23 | areAmicableNumbers x y = [(sum [k | k <- [1..x], x `mod` k ==0]) == y] && [(sum [i | i <- [1..y], y `mod` i ==0]) == x]
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Homework1.hs:23:75: error:
    * Couldn't match expected type `Bool' with actual type `[Bool]'
    * In the second argument of `(&&)', namely
        `[(sum [i | i <- [1 .. y], y `mod` i == 0]) == x]'
      In the expression:
        [(sum [k | k <- [1 .. x], x `mod` k == 0]) == y]
          && [(sum [i | i <- [1 .. y], y `mod` i == 0]) == x]
      In an equation for `areAmicableNumbers':
          areAmicableNumbers x y
            = [(sum [k | k <- [1 .. x], x `mod` k == 0]) == y]
                && [(sum [i | i <- [1 .. y], y `mod` i == 0]) == x]
   |
23 | areAmicableNumbers x y = [(sum [k | k <- [1..x], x `mod` k ==0]) == y] && [(sum [i | i <- [1..y], y `mod` i ==0]) == x]
   |                                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.

1==1 的类型为 Bool.

[1==1] 的类型为 [Bool].

(&&) 需要两个 Bool 类型的参数。相反,它会找到两个 [Bool] 类型的参数。这两种类型是不同的。程序因此被否决。

GHCi> :type (&&)
(&&) :: Bool -> Bool -> Bool

> :type (&&) :: [Bool] -> [Bool] -> [Bool]

<interactive>:1:1:
    Couldn't match type `Bool' with `[Bool]'
    Expected type: [Bool] -> [Bool] -> [Bool]
      Actual type: Bool -> Bool -> Bool
    In the expression: (&&) :: [Bool] -> [Bool] -> [Bool]

你测试的方括号是错误的。他们不应该在那里。

GHCi> :type [1==1] :: Bool

<interactive>:1:1:
    Couldn't match expected type `Bool' with actual type `[Bool]'
    In the expression: [1 == 1] :: Bool

GHCi> :type (1==1)
(1==1) :: Bool