Skip to content
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

Wrap the Shake functions with newtypes #1753

Merged
merged 6 commits into from
Apr 19, 2021
Merged

Conversation

ndmitchell
Copy link
Collaborator

To ensure that we really are using our own types, and our own library, it's useful to newtype wrap the Action, ShakeOptions and Rules types. That means that if we accidentally use Shake, it's a type error. It's also step 1 towards replacing Shake, but even if we don't, it makes the abstraction more robust.

In order to further enhance the abstraction, I've changed addBuiltinRule for addRule which doesn't do the linting and tracking stuff, and simplified the "extra" feature in Shake to only allow a single value, as that's all we need. Fairly minor changes, but cut down on the complexity of the interface to Shake, where we're only using a subset.

There's a potential performance cost to newtype wrapping when it's a list, but if we had to we could switch to the newtype coercion stuff, and these aren't performance sensitive bits, so it's will be negligible. (I ran a benchmark, and saw no change beyond random variation.)

I haven't tried to wrap all Shake types, as that doesn't really give any benefits, but that might be a reasonable end goal in the future.

@ndmitchell ndmitchell added the merge me Label to trigger pull request merge label Apr 18, 2021
@mergify mergify bot merged commit dec47a3 into haskell:master Apr 19, 2021
@ndmitchell ndmitchell deleted the wrap-shake branch April 19, 2021 08:35
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Apr 23, 2021
* Add a function addRule, which abstracts over addBuiltinRule

* Newtype wrap the Action, Rules and ShakeOption types

* Replace addShakeExtra with newShakeExtra

* Move the internals of hls-graph around a bit

* Expose shakeTimings and shakeAllowRedefineRules through ShakeOptions

Co-authored-by: Potato Hatsue <1793913507@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants