我对 haskell 非常陌生,我接到一个任务,要创建一个属性列表,然后创建一个函数,输出适用于输入的属性列表,但由于某种原因,它只给我一个错误。下面是代码片段和错误
properties :: [Predicate Thing]
properties = [isBlue, isThick, isThin, isOrange, isDisc, isSquare, isBig, isSmall]
propertiesOf :: Thing -> [Predicate Thing]
propertiesOf x = [props | props <- properties, props x == True]
错误如下:
<interactive>:8:1: error: [GHC-39999] * No instance for Show (Thing -> Bool)'arising from a use of print' (maybe you haven't applied a function to enough arguments?) * In a stmt of an interactive GHCi command: print it
我希望输入一个橙色的、圆盘状的、大而厚的“东西”,并接收输出:
>[isBig, isDisc, isOrange, isThick]
我不确定为什么上面列出的功能不起作用。