Here's the code as part of a coding exercise (the 2nd one) here:
module CartesianProductExercise where
import Prelude
import Data.Tuple (Tuple(..))
cartesianProduct :: ∀ a b. Array a -> Array b -> Array (Tuple a b)
cartesianProduct left right = do
a_ <- left
b_ <- right
pure[ Tuple a_ b_ ]
The error that spago returns is:
Compiling CartesianProductExercise
Error found:
in module CartesianProductExercise
at src/CartesianProductExercise.purs:9:3 - 9:13 (line 9, column 3 - line 9, column 13)
Could not match type
Array
with type
Tuple a0
while trying to match type Array (Tuple a0 b1)
with type Tuple a0 b1
while checking that expression (bind left) (\a_ ->
(bind right) (\b_ ->
...
)
)
has type Array (Tuple a0 b1)
in value declaration cartesianProduct
where b1 is a rigid type variable
bound at (line 0, column 0 - line 0, column 0)
a0 is a rigid type variable
bound at (line 0, column 0 - line 0, column 0)
See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
or to contribute content related to this error.
[error] Failed to build.
What I'm trying to do is specify a Tuple
so that I can match the types of the two arrays.
Can anyone help?