I’m playing around with some graph data structures in Purescript using Tuples. The following does not compile, even though as I reason through all the types, it ought to by my reckoning. The checker does not seem to recognise s
as a List
of Tuple b Node
. I realise in Purescript typically records are recommended for this sort of thing, but I guess I am just curious what is going on. Or have I made some oversight that I can’t see?
You can paste these lines directly into Try.
type Node = Int
type Context' a b = Tuple3 (Adj b) a (Adj b)
type Adj b = List (Tuple b Node)
addSucc :: forall a b. Node -> b -> Context' a b -> Context' a b
addSucc v l (p /\ l' /\ s) = (p /\ l' /\ ((l /\ v): s))
Error returned
Could not match type
Tuple (List (Tuple b0 Int))
with type
List
while trying to match type t1
with type List (Tuple b0 Int)
while checking that expression s
has type List (Tuple b0 Int)
in value declaration addSucc
where b0 is a rigid type variable
bound at (line 0, column 0 - line 0, column 0)
t1 is an unknown type