-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Rule inputs alternate hasinput class #4406
base: master
Are you sure you want to change the base?
Rule inputs alternate hasinput class #4406
Conversation
sketch of what I was saying on the call: type family RuleInput k :: Type
newtype ProjectHaskellFile = ProjectHaskellFile NormalizedFilePath
-- examples
type instance RuleInput GhcSession = ProjectHaskellFile
type instance RuleInput GetClientSettings = ()
-- various stuff might require `RuleInputFromFilePath (RuleInput r)`
-- which basically says you have a way to convert a filepath into
-- input for the rule, possibly failing
class RuleInputFromFilePath i where
toRuleInput :: NormalizedFilePath -> Either String i
-- example
someRule = do
...
validFp <- case toRuleInput nfp of
Right p -> pure p
Left e -> ... some error ...
use someRule validFp |
@michaelpj The problem with that approach is that for some rules, both project haskell files and dependency haskell files are valid inputs. This is why I distinguish between the |
Sure, so then you would need to have |
Instead of type level list inclusion for
HasInput
, this enumerates all of the instances andValidInputs
is a sum type.