I noticed that the definition of Capture is data Capture (sym :: Symbol) a. The problem with this is that it allows me to write nonsense like Capture "foo" Maybe :> Post '[JSON] (), and only get a type error later when matching up the implementations with the type specs. The error would be much nicer if the definition of Capture was instead data Capture (sym :: Symbol) (a :: *). Similar should be done for some other types, definitely CaptureAll, ReqBody, QueryParam, QueryParams. BasicAuth already has it. This is not by any means an exhaustive list. I'm new to servant and I just opened up a few modules to see how widespread this was.
I think this will make some errors a bit kinder.
Also, I was quite confused that I was able to write Capture "foo" :> Post '[JSON] (). Note the missing type argument on Capture. I suppose the reason this isn't done is that it's desired to have an open world of types for APIs, and we don't have anything like "kind constraints"? I guess I'm spoiled by typechecking and expect similar at the kind level.
I noticed that the definition of
Captureisdata Capture (sym :: Symbol) a. The problem with this is that it allows me to write nonsense likeCapture "foo" Maybe :> Post '[JSON] (), and only get a type error later when matching up the implementations with the type specs. The error would be much nicer if the definition ofCapturewas insteaddata Capture (sym :: Symbol) (a :: *). Similar should be done for some other types, definitelyCaptureAll,ReqBody,QueryParam,QueryParams.BasicAuthalready has it. This is not by any means an exhaustive list. I'm new to servant and I just opened up a few modules to see how widespread this was.I think this will make some errors a bit kinder.
Also, I was quite confused that I was able to write
Capture "foo" :> Post '[JSON] (). Note the missing type argument onCapture. I suppose the reason this isn't done is that it's desired to have an open world of types for APIs, and we don't have anything like "kind constraints"? I guess I'm spoiled by typechecking and expect similar at the kind level.