- where
-
- -- Get the datatype for the type at hand;
- -- use gdefault to provide the type at hand.
- myDataTypeOf :: Data a => ReadP a -> DataType
- myDataTypeOf (_::ReadP a) = dataTypeOf (undefined::a)
-
- -- Turn string into constructor driven by gdefault's type,
- -- failing in the monad if it isn't a constructor of this data type
- str2con :: String -> ReadP Constr
- str2con = maybe mzero return
- . stringCon (myDataTypeOf gdefault)
+ -- Turn string into constructor driven by the requested result type,
+ -- failing in the monad if it isn't a constructor of this data type
+ str2con :: String -> ReadP Constr
+ str2con = maybe mzero return
+ . readConstr myDataType