I would like to add type signatures to some local functions in my code. However, their types involve anonymous, existentially bound type variables. Since they're anonymous, I don't know how to write a type signature. How can I refer to such type variables?
In the following example, go
has type [b] -> Int -> Int
, where b
is the type bound by the pattern match T (x_shared:xs) g
. What type signature can I write for it?
data T = forall a. T [a] (a -> a -> Int)
f :: T -> Int
f (T (x_shared:xs) g) = go xs 0
where
-- go :: what type?
go (x:xs) n = go xs $! n + g x_shared x
go [] n = n