-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
Servant.API.TypeLevel #345
Conversation
795182e
to
5f678cc
Compare
|
||
type family Elem e es :: Constraint where | ||
Elem x (x ': xs) = () | ||
Elem y (x ': xs) = Elem y xs |
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.
The similar version in -foreign can be removed in favour of this one, I think.
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.
Done.
Also fixes #121 |
LGTM |
I don't know much about type families yet, but also LGTM. 👍 |
LGTM 👍 |
FYI: some more cool stuff is being embedded in |
The only issue i have with this is style: indentation is very inconsistent, sometimes i see 2 spaces, sometimes 4. Can i propose 2 spaces for the whole repo? We have to deal with huge type declarations and systematically having code closer to the left side will do some good IMHO. |
@@ -86,6 +85,8 @@ | |||
-- bad_link under api after trying the open (but empty) type family | |||
-- `IsElem'` as a last resort. | |||
module Servant.Utils.Links ( | |||
module Servant.API.TypeLevel, |
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.
shouldn't this be at the bottom of export list?
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.
there'll be some warning if anything will be shadowed afaik
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.
@dredozubov: I don't fully understand your comment. What is shadowed by what here? In any case I would expect the order of the export list to be irrelevant.
@dredozubov I am in favour of 2 spaces too. It has also been brought to our attention that |
@fizruk I personally feel like adding singletons to the dependency list is like opening a gateway to hell. In my experience it quickly escalates to the longer compile-time and awkward(IMHO) type signatures, because "we already have singletons as a dep, why not do X?". To make picture fuller, there is also https://hackage.haskell.org/package/type-fun |
@dredozubov that is my only concern so far, yes. |
What is holding us back currently to merge this? Except from the discussion whether we want to add an extra dependency for type-level utility functions? |
@arianvp tests are still missing and there are also few things in I am currently overloaded at work so I won't be able to work on this in the next couple of weeks. |
Do I misunderstand this PR? This isn't adding new functionality, but moving scattered functions to a common module, right? If so, I don't think we should require new tests for this to go in. Also, adding additional functions from elsewhere should be a separate PR. And I'd vote against adding a dependency on singletons if it can be avoided. As far as this is just a refactoring (which I thought it was), I'm happy for it to be merged. |
@kosmikus there is new functionality here, e.g. Over the time My idea was to figure out all useful types in |
I see. But then, why should all this be added to the |
@kosmikus well, maybe. But if we go with Most of the type-level code is actually very general and not related to I also think type-level functions like
IMO, these are not just some type functions "anyone could ever need", but rather "anyone building a servant-something library should probably use". Think In any case, feel free to kill this PR and introduce another one which would just put existing things in one place. We can discuss all the extra type-level functions in a separate issue/PR. |
I definitely agree that there are probably a whole lot of useful type-level functions in the context of servant, and that it makes sense to provide them, rather than letting every user of servant reinvent them. So for the time being, I'm happy to go with the approach proposed here. It just think we should keep an eye on how much we'll accumulate over time. As long as there are no new external dependencies (such as singletons) introduced by this effort, I think we're probably ok. |
1304b17
to
01d4a83
Compare
I just rebased against master. @haskell-servant/maintainers can I merge? As far as I can tell we have two +1s from before, unless something changed. |
abb35da
to
37c4bb8
Compare
I'm happy to give this another review before merging. |
import Servant.API.Header ( Header ) | ||
import Servant.API.Verbs ( Verb ) | ||
import Servant.API.Sub ( type (:>) ) | ||
import Servant.API.Alternative ( type (:<|>) ) |
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.
Whitespaces are inconsistent.
Added loads of doctests and other documentation. |
Can we also squash the commits before merging, please? |
Yup. Got some more work to do first though. On Thu, Aug 25, 2016 at 08:24:45AM -0700, Sönke Hahn wrote:
Julian K. Arni |
-- ... '["hello" :> Verb 'GET 200 '[JSON] Int, | ||
-- ... "bye" | ||
-- ... :> (Capture "name" String | ||
-- ... :> Verb 'POST 200 '[JSON, PlainText] Bool)] |
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.
I wouldn't use ...
and just match ghc
's indentation.
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.
I feel like that'd be testing indentation, and might break more easily across GHC versions?
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.
I just think it's confusing in the documentation. Other than that, I would run the doctests with one ghc
version only. (As discussed before.)
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.
Used Refl
to make GHC decide type-equality
So If yes, we should name all these things differently, IMO. |
Yes
Agreed. How about More generally, what actually is the correct terminology to distinguish between these things? |
d949fa1
to
3c83f61
Compare
is @fizruk happy with the current state of this PR? As I pointed above, name bike-shedding can be done later. |
ElemGo x '[] orig = ElemNotFoundIn x orig | ||
#endif | ||
|
||
-- ** Logic |
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 it worth having sections in both code and export list?
Also this one is missing in the export list.
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.
I usually keep some section indicators in the code as well, so it's organised as well. (Sometimes sections in code are in the different order though, thanks to Template Haskell).
Added Logic subsection to the export list.
Ok, I'm happy with the current state of this PR. 👍 |
Closes #305.
I need to write some tests, otherwise, should be complete.