我看到你可以使用多次投影的函数创建类型同义词,但我不太明白应该如何使用它。
这是我刚刚编写的一个示例,我想这会显示这样一个用例,但我无法定义函数throwParty
。我将如何使用这种类型的同义词?
我的例子
type DamagedFurniture = String
type Person = String
type Friend = Person
type Acquaintances = Person -> Friend -> [Person]
throwParty :: Person -> Acquaintances -> DamagedFurniture
答案 0 :(得分:3)
这相当于
throwParty :: Person -> (Person -> Friend -> [Person]) -> DamagedFurniture
而不是
throwParty :: Person -> Person -> Friend -> [Person] -> DamagedFurniture
你可以做的事情是:
type AcquaintancesTo a = Person -> Friend -> [Person] -> a
throwParty :: Person -> AcquaintancesTo DamagedFurniture