updated documentation strings to include empty tag in a union#2625
updated documentation strings to include empty tag in a union#2625amkhlv wants to merge 3 commits intodhall-lang:mainfrom
Conversation
Gabriella439
left a comment
There was a problem hiding this comment.
I think this is what you want
| adapt (Queued n) = Just (Left n) | ||
| adapt (Result t) = Just (Right (Left t)) | ||
| adapt (Errored e) = Just (Right (Right e)) | ||
| adapt Unreachable = Nothing |
There was a problem hiding this comment.
| adapt (Queued n) = Just (Left n) | |
| adapt (Result t) = Just (Right (Left t)) | |
| adapt (Errored e) = Just (Right (Right e)) | |
| adapt Unreachable = Nothing | |
| adapt (Queued n) = Left n | |
| adapt (Result t) = Right (Left t) | |
| adapt (Errored e) = Right (Right (Left e)) | |
| adapt Unreachable = Right (Right (Right ())) |
| adapt (Queued n) = Just (Left n) | ||
| adapt (Result t) = Just (Right (Left t)) | ||
| adapt (Errored e) = Just (Right (Right e)) | ||
| adapt Unreachable = Nothing |
There was a problem hiding this comment.
| adapt (Queued n) = Just (Left n) | |
| adapt (Result t) = Just (Right (Left t)) | |
| adapt (Errored e) = Just (Right (Right e)) | |
| adapt Unreachable = Nothing | |
| adapt (Queued n) = Left n | |
| adapt (Result t) = Right (Left t) | |
| adapt (Errored e) = Right (Right (Left e)) | |
| adapt Unreachable = Right (Right (Right ())) |
There was a problem hiding this comment.
I think I am getting a bit lost. The documentation on Hackage --- I think it is different from the docstring in the source file which I have been editing. Is this a newer version? What does the adapt function do?
That's why I wanted to compile it, to see the up-to-date documentation. But I could not compile it...
There was a problem hiding this comment.
Yeah, it's been a while since the last release to Hackage, which is the reason for the difference. However, I'm working on cutting a new release soon
There was a problem hiding this comment.
Stackage would also be great. It would enable Hoogle...
| data Status = Queued Natural | ||
| | Result Text | ||
| | Errored Text | ||
| | Unreachable () |
There was a problem hiding this comment.
| | Unreachable () | |
| | Unreachable |
There was a problem hiding this comment.
This is how I had it:
data DateFinished = Current () | Done DATE.Day | Dropped () deriving (Generic, Show, Eq)
and then:
dateFinishedDecoder :: Decoder DateFinished
dateFinishedDecoder =
union
( (Current <$> constructor "Current" unit)
<> (Done <$> constructor "Done" day)
<> (Dropped <$> constructor "Dropped" unit)
)
But if I do as you suggested, i.e. data DateFinished = Current | Done DATE.Day | Dropped deriving (Generic, Show, Eq) --- then it does not compile
There was a problem hiding this comment.
If you change that to:
dateFinishedDecoder :: Decoder DateFinished
dateFinishedDecoder =
union
( (Current <$ constructor "Current" unit) -- Carefully note the `<$`
<> (Done <$> constructor "Done" day)
<> (Dropped <$> constructor "Dropped" unit)
)… then it should compile
There was a problem hiding this comment.
Oh, I got it ! Cute (although smells of witchcraft...). Then, maybe, instead of my suggested patch, would you rather write something pedagogical, in that docstring?
There was a problem hiding this comment.
I just requested the pull for the correcting patch, as you suggested.
The existing documentation on
uniondecoder misses the case when one of constructors is an empty tag. This patch adds an example of that.