Sorry if the title is ambiguous, essentially I have the following data type declarations:
type Domino = (Integer, Integer)
type Hand = [Domino]
type Board = [Domino]
type DomsPlayer = Hand -> Board -> (Domino, End)
type Score = (Integer, String)
and a function:
playDomsRound :: DomsPlayer -> DomsPlayer -> Int -> (Score, Score)
how do I go about calling the playDomsRound function?
The Cardinal Rule of Typed Application in Haskell is, very simply,
f :: a -> b ===
f (x :: a) :: b
Thus, in your case,
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)
and you can write any of the above in your code.
Any expression which has a type, can appear in your code.
Since you've defined
type DomsPlayer = Hand -> Board -> (Domino, End)
the type DomsPlayer is the same as the type Hand -> Board -> (Domino, End). This is what your playDomsRound expects: a function. Not yet applied to any of the arguments that it expects. Just a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With