You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since all vectors declare themselves to be NoRepTypes, the uniplate library (and probably others) immediately stop traversing on encountering a vector. This seems to me like it's probably not the intended behaviour for immutable vectors. (For mutable ones it's a different matter, of course.)
So, unless I'm mistaken, I'd like to suggest that immutable vector types follow the lead of Set and friends, and have Data instances along the lines of the following (but presumably defined once and for all in ...Generic like now):
instanceDataa=>Data (Vectora) where
gfoldl f z m = z fromList `f` toList m
toConstr _ = fromListConstr -- was: error "toConstr"
gunfold k z c =case constrIndex c of-- was: error "gunfold"1-> k (z fromList)
_ ->error"gunfold"
dataTypeOf _ = vectorDataType -- was: mkNoRepType "Data.Vector.Vector"
dataCast1 f = gcast1 f
fromListConstr::Constr
fromListConstr = mkConstr vectorDataType "fromList"[]PrefixvectorDataType::DataType
vectorDataType = mkDataType "Data.Vector.Vector" [fromListConstr]
The text was updated successfully, but these errors were encountered:
Indeed, the current Data instances seem strangely inconsistent, since we implement gfoldl f z m = z fromList f toList m but don't implement other methods in a similar fashion.
Your proposed implementation sounds sensible to me—care to make a pull request?
The following GHCI session illustrates what I'm talking about:
Since all vectors declare themselves to be
NoRepType
s, the uniplate library (and probably others) immediately stop traversing on encountering a vector. This seems to me like it's probably not the intended behaviour for immutable vectors. (For mutable ones it's a different matter, of course.)So, unless I'm mistaken, I'd like to suggest that immutable vector types follow the lead of
Set
and friends, and haveData
instances along the lines of the following (but presumably defined once and for all in...Generic
like now):The text was updated successfully, but these errors were encountered: