Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 如何组合返回Bool的函数_Haskell - Fatal编程技术网

Haskell 如何组合返回Bool的函数

Haskell 如何组合返回Bool的函数,haskell,Haskell,有没有办法将这些函数组合在一起 data Patient = Patient { name :: Name, sex :: Sex, age :: Int, height :: Int, weight :: Int, bloodType :: BloodType } canDonate :: BloodType -> BloodType -> Bool canDonateTo :: Patient -> Patient -&g

有没有办法将这些函数组合在一起

data Patient = Patient
  { name :: Name,
    sex :: Sex,
    age :: Int,
    height :: Int,
    weight :: Int,
    bloodType :: BloodType
  }

canDonate :: BloodType -> BloodType -> Bool

canDonateTo :: Patient -> Patient -> Bool

目前我只是手动应用它们

canDonateTo :: Patient -> Patient -> Bool
canDonateTo x y = canDonate (bloodType x) (bloodType y)
但是,我想知道是否有更好的方法。使用:

(基本上,您的方法只是在上内联了
的定义,可以定义为

on f g x y = f (g x) (g y)

)

我更喜欢你的方式,而不是
Data.Function.on
on f g x y = f (g x) (g y)