advancedtelematic / quickcheck-state-machine

Test monadic programs using state machine based models
Other
203 stars 25 forks source link

Read instance for Commands #370

Closed Tarmean closed 4 years ago

Tarmean commented 4 years ago

It would be nice if Commands could be read. My motivation is writing out the Commands into a file during testing and then having a --rerun option on the test runner to quickly repeat the last failed test.

Alternatively GHC can derive these as orphan instances in applications so this would be more of a nice quality of live improvement.

Costs: The deriving requires an unfortunate amount of language extention so maybe they should live in a seperate file.

{-# Language StandaloneDeriving, FlexibleInstances, FlexibleContexts, UndecidableInstances #-}

deriving instance Read (SM.Var)
deriving instance (Read (l SM.Symbolic), Read (r SM.Symbolic), Read (l SM.Concrete), Read (r SM.Concrete)) => Read (SM.Commands l r)
deriving instance (Read (l SM.Symbolic), Read (r SM.Symbolic), Read (l SM.Concrete), Read (r SM.Concrete)) => Read (SM.Command l r)
deriving instance (Read (b a)) => Read (SM.Reference a b)
deriving instance (Typeable a, Read a) => Read (SM.Concrete a)
deriving instance (Typeable a) => Read (SM.Symbolic a)
stevana commented 4 years ago

There's already a Read instance for Commands. Also see saveCommands and runSavedCommands.

Tarmean commented 4 years ago

Oh, really thought I was on the latest version. Thank you for awesome work on this and sorry for the noise!