Reputation: 694
I have a data structure with a type parameter called Fluent
.
I want a list of these. What's the most elegant way to fix this code?
data Fluent t = Fluent [t]
data Obj = Obj [Fluent]
Edit: I want to be able to do this:
f1 = Fluent [True, False]
f2 = Fluent [1, 2, 3, 4]
let o = Obj [f1, f2]
Upvotes: 0
Views: 56
Reputation: 91857
You have to propagate the type parameter t
up to the Obj type:
data Fluent t = Fluent [t]
data Obj t = Obj [Fluent t]
:t Obj $ map Fluent ["a", "bcd"] -- Obj Char
Upvotes: 3