-
Notifications
You must be signed in to change notification settings - Fork 1
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
make Delayed type abstract #127
Conversation
For symmetry with |
src/Formula/Parsing/Delayed.hs
Outdated
newtype Delayed a = Delayed String deriving (Eq, Typeable, Generic) | ||
|
||
instance Show (Delayed a) where | ||
show (Delayed str) = str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there even a need for a Show
instance for Delayed
now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment it is used for the Hashable (Delayed a)
instance in Autotool. At the "expense" of a hashable
dependency the instance could be defined here instead (making it also non-orphan).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why is Hashable (Delayed a)
even needed? I guess I am still struggling to get to grips with the role of Delayed
. There shouldn't be a task type that has Delayed
as its input type, nor inside a configuration or instance type, right? That is the whole point of having things like
type CnfString = String
instance Partial TruthTableMaxterm MaxInst CnfString where
in Autotool, not
instance Partial TruthTableMaxterm MaxInst (Delayed Cnf) where
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. It is not needed. I transformed the actual string input too early in a few cases where completeGrade
is used inside of toReporterWithGlobalPics
which requires Hashable
inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does something similar apply to the Eq, Typeable, Generic
instances?
Due to the peculiar role of Delayed
, the pull request's intention really was to "isolate" it somewhat from the rest of the code via making it as abstract as possible. Any provided type class instance of course makes it a bit less abstract, since one can then learn something about internals of a delayed value.
Should the signature of The obvious |
I'd say that After all, the point of the abstraction is not really to guard against "malicious actors" here, but against "accidental misuse". If someone calls |
@owestphal, wouldn't it be better to hide the data constructor of the
newtype
thus?I've also been thinking about further replacing
by
and
by
Is there a need somewhere to really have the default derived
Show
instance forDelayed
, i.e., with"Delayed "
being output?