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
prefer String instance of ToYaml over [Char] #186
Conversation
I'd be very nervous about including |
Sorry for the lack of explanation. The current String instance overlaps with the general [a] instance. As I understand it, without some guidance, GHC won't pick between them; my attempts to call toYaml on String do not compile. I think OVERLAPPING is less intrusive than OVERLAPPABLE on the [a] instance. |
The |
This one's my fault for not adding a test that called I was under the impression that the constraint on instance ToYaml a => ToYaml [a] where
toYaml = array . map toYaml would mean that the instances aren't overlapping since there's no I had a look at how the list instance works for I don't know if that mess is more or less desirable than using |
I think adding a list method to My understanding is that GHC looks for an instance that matches right of the |
I don't use this particular API myself. But my leaning is to avoid usage of |
Below are a few tests that I believe cover the instance resolution. I have a somewhat larger project that uses import Data.Yaml.Builder
λ BS.putStrLn $ toByteString ([1..4] :: [Int])
- 1
- 2
- 3
- 4
λ BS.putStrLn $ toByteString "a single string"
a single string
λ BS.putStrLn $ toByteString (words "several strings in a list")
- several
- strings
- in
- a
- list |
OK, I'm fine with including this change as-is. Would you mind adding a ChangeLog entry and minor version bump? |
No description provided.