-
Notifications
You must be signed in to change notification settings - Fork 32
Refined derives Typeable and Data #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Note that |
Thanks for quick feedback. I reverted Typeable deriving. |
|
Could you give an estimate for next release? |
|
I'm unclear on what this could accomplish currently. In particular, I don't think predicates should have instances, since they should never be instantiated on the term level in the first place. (My rewrite rerefined doesn't even provide constructors.) May I ask what problem you're trying to solve @yaitskov ? Does a |
|
I am against this primarily because these typeclasses are used to inspect and modify runtime values, and like @raehik says, it's not clear that predicates should ever be constructed. |
|
You are an author of rerefined and maintain refined - this is conflict of interest ;) |
|
I don't see any use for it either but I might be missing something. @yaitskov can you provide a motivating information on why you think it's needed? |
|
GHC requires all record fields to have Data instance to derive data for the record type. {-# LANGUAGE TemplateHaskell #-}
module CallSpecs where
import System.Process.Quick
$(genCallSpec
[TrailingHelpValidate, SandboxValidate]
"cp"
( VarArg @(Refined (InFile "hs") FilePath) "source"
.*. VarArg @(Refined (OutFile "*") FilePath) "destination"
.*. HNil
)
)
main :: IO ()
main = callProcess $ Cp $(refinedTH "app.hs") $(refinedTH "app.bak")These record types have Arbitrary instance too. |
|
Thanks! @raehik @chessai What do you guys think? Seems reasonable to me. We should also discuss the downsides of adding this letting us conclude whether it's worth it. Also possibly find dedicated solutions for some of them. E.g., one downside that I see is that we'll thus be making Data essentially a required constraint for all predicates including custom ones. Does anyone see more downsides? @yaitskov Do you have any ideas how your problem could be solved without necessarily adding the Data instances? |
|
An alternative to gmapM is to use TH, which should be faster than Data driven solution and the library already seats up to the ears in Q monad, but it requires more development and maintenance; performance gain is not critical. As for now I successfully merged modified version of refined as an internal library thanks to its tiny code base. Another improvement for refined library, that crawled through my head, but left unimplemented, is smarter Arbitrary instance, because And/Or/Not predicate combinators are not scalable - the arbitrary Refined method for a complex expression cannot succeeded after 100 attempts. |
|
Sorry for my late response here. data Test = Test (Refined (LessThan 1) Int) deriving Datadidn't need me to define Regarding the |
Now taking into fact that Refined data constructor is exposed in Refined.Unsafe.Type this PR seems redundant, but I tried today and I was not able to succeed. Library location https://github.com/yaitskov/quick-process
|
No description provided.