Reputation: 32129
I'm quite new to Haskell and I'm trying to use a type variable from the function declaration in the creation (not quite sure what to call this in Haskell) of a record type.
As always, code explains my problem a lot better:
data S a = S {x::a}
f :: a -> S a
f n = (S a){x=n}
GHC says that a is not in scope on the last line. How could this be accomplished?
Upvotes: 1
Views: 133
Reputation: 170899
In cases where you do need the type variable from declaration, use the scoped type variables extension.
Upvotes: 1