Extracting an Id with GHC.Generics
问题 How to extract an identifier (in this case an integer) from a structure using GHC.Generics ? I have an Id type: newtype Id = Id { _id :: Int } and a lot of types that use that type: data VarId = VarId Name Id SortId data FuncId = FuncId Name Id [SortId] SortId data SortId = Name Id -- ... and 20 more of these things On top of that there are other types that wrap the types above, for instance, identifiers: data Identifier = IdVar VarId | IdFunc FuncId | IdSort SortId -- ... and 20 more of