很抱歉,如果标题不明确,基本上我有以下数据类型声明:
type Domino = (Integer, Integer)
type Hand = [Domino]
type Board = [Domino]
type DomsPlayer = Hand -> Board -> (Domino, End)
type Score = (Integer, String)
和一个功能:
playDomsRound :: DomsPlayer -> DomsPlayer -> Int -> (Score, Score)
如何调用playDomsRound函数?
答案 0 :(得分:3)
Haskell中的键入应用程序的基本规则非常简单,
f :: a -> b ===
f (x :: a) :: b
因此,在您的情况下,
playDomsRound :: DomsPlayer -> DomsPlayer -> Int -> (Score, Score) ===
playDomsRound (p :: DomsPlayer) :: DomsPlayer -> Int -> (Score, Score) ===
playDomsRound (p :: DomsPlayer) (q :: DomsPlayer) :: Int -> (Score, Score) ===
playDomsRound (p :: DomsPlayer) (q :: DomsPlayer) (i :: Int) :: (Score, Score)
您可以在代码中编写上述任何内容。
任何具有类型的表达式都可以出现在您的代码中。
因为你已经定义了
type DomsPlayer = Hand -> Board -> (Domino, End)
类型DomsPlayer
与类型Hand -> Board -> (Domino, End)
相同。这就是你的playDomsRound
所期望的:一个函数。尚未应用于 it 期望的任何参数。只是一个功能。