New module: Control.Rematch.Data, for data type generic matchers #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
using the Data.Data.Data typeclass, isDataConstr and isDataValue
Examples:
`import Data.Data
import Contorl.Rematch
import Control.Rematch.Data
data MyStructure = First | Second Int | Third Bool String deriving (Data)
myTests = [runMatch (isDataConstr Second) First,
runMatch (isDataConstr Second) $ Second 4,
runMatch (isDataValue Second 0 $ equalTo 10) $ Second 10,
runMatch (isDataValue Third 1 $ equalTo "Hello") $ Third False "Goodbye"]`
(with obviously the second and third matchers succeeding while the others fail)
I've isolated this pull request from my others, but this does mean some (relatively trivial) merging work would be required to accept all of them. If you decide to do so, it may be easier to directly pull my changes from my fork's master rather than merge them manually.