Changed findMeta so that it would work even if the Meta data was not the first direct child of an item

This commit is contained in:
Neil Brown 2008-02-23 18:33:39 +00:00
parent 635f7bf1b0
commit ae49d236d6

View File

@ -71,8 +71,8 @@ unpackMeta s = (Nothing, s)
findMeta :: (Data t, Typeable t) => t -> Meta findMeta :: (Data t, Typeable t) => t -> Meta
findMeta e = case cast e of findMeta e = case cast e of
Just m -> m Just m -> m
Nothing -> if null metaList then emptyMeta else head metaList Nothing -> if null (concat metaList) then emptyMeta else head (concat metaList)
where where
metaList = gmapQ (mkQ emptyMeta findMeta') e metaList = gmapQ (mkQ [] findMeta') e
findMeta' :: Meta -> Meta findMeta' :: Meta -> [Meta]
findMeta' m = m findMeta' m = [m]