Gần đây tôi đã cài đặt Eclipse Eclipse plugin "EclipseFP" của Haskell. Mọi thứ hoạt động khá tốt trong khi có một tính năng khiến tôi rất tức giận hehe. Tôi không thể giảm mức cảnh báo của đầu ra. Eclipse/Plugin của nó có vẻ tự động gắn thêm cờ "-Wall", rất nhạy cảm với kiểu-thứ. Hãy hiển thị điều này trên ví dụ:Giảm mức cảnh báo của Eclipse (loại)
*Main> head [1,2,3]
<interactive>:1:11:
Warning: Defaulting the following constraint(s) to type `Integer'
(Num a0) arising from the literal `3'
In the expression: 3
In the first argument of `head', namely `[1, 2, 3]'
In the expression: head [1, 2, 3]
<interactive>:1:11:
Warning: Defaulting the following constraint(s) to type `Integer'
(Num a0) arising from the literal `3' at <interactive>:1:11
(Show a0) arising from a use of `print' at <interactive>:1:1-12
In the expression: 3
In the first argument of `head', namely `[1, 2, 3]'
In the expression: head [1, 2, 3]
1
*Main>
Đúng, điều đó thực sự gây khó chịu. Nó được gây ra bởi các chức năng "nội tại" cũng như các chức năng tùy chỉnh. Một số khác:
factorial :: (Integral a) => a -> a
factorial 1 = 1
factorial n = n * factorial (n-1)
*Main> factorial 3
<interactive>:1:1:
Warning: Defaulting the following constraint(s) to type `Integer'
(Integral a0) arising from a use of `factorial'
at <interactive>:1:1-9
(Num a0) arising from the literal `3' at <interactive>:1:11
In the expression: factorial 3
In an equation for `it': it = factorial 3
<interactive>:1:1:
Warning: Defaulting the following constraint(s) to type `Integer'
(Integral a0) arising from a use of `factorial'
at <interactive>:1:1-9
(Num a0) arising from the literal `3' at <interactive>:1:11
(Show a0) arising from a use of `print' at <interactive>:1:1-11
In the expression: factorial 3
In an equation for `it': it = factorial 3
6
*Main>
Bạn sẽ viết mã này như thế nào để cảnh báo không hiển thị ngay từ đầu? –