Skip to content

Conversation

@arbuztw
Copy link

@arbuztw arbuztw commented Oct 1, 2017

Fixes #15.

fromParam [x] = Right x
fromParam [] = Left ParamMissing
fromParam _ = Left ParamTooMany
instance {-# INCOHERENT #-} FromParam String where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me a little more about why "INCOHERENT" is needed here? I've never seen it before.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. The reason is that String is actually [Char] and so GHC complains that it is overlapped with the FromParam [a] instance below. (According to the doc, GHC will not take context (i.e. constrains before =>) into account when matching instances.)
One solution is to add "INCOHERENT" pragma according to this. I am not sure if there is a better solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Let me think a little about whether this feature is worth that extra bit of type complexity. Regardless I appreciate you taking the time to make this PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants