Implementing: complex-numbers#601
Implementing: complex-numbers#601petertseng merged 13 commits intoexercism:masterfrom Average-user:complex_implement
Conversation
|
How can I check the Travis build before upload? |
You may see the exact commands that the travis runs by looking at https://github.com/exercism/haskell/blob/master/.travis.yml#L23-L49 . You may run any or all of those commands on your own computer. |
|
@petertseng Also, there is a way to don't have to follow the HLints suggestions? Sometimes the extra parentheses can help to read something, I believe. |
https://github.com/exercism/haskell/blob/master/README.md#running-hlint |
|
@petertseng I want your feedback about if it is Float the right type for this, maybe, I don't really know. Or maybe is it better tu use mixed types |
I'm not sure I understood the question correctly. I think my answer is "as long as it passes the tests, it doesn't matter what the internal implementation details are", right? |
| "core": false, | ||
| "unlocked_by": null, | ||
| "difficulty": 2, | ||
| "topics": [ |
There was a problem hiding this comment.
I think I will feel the urge to remove this. I will feel bad having this exercise with "mathematics" topic, and none of the other exercises that should have "mathematics" topic have it. It isn't one that would affect a placement decision (the topics added in #476 ).
I guess I would accept a PR that adds the mathematics topic to all the exercises that should have it.
There was a problem hiding this comment.
Maybe I'll do that.
| "unlocked_by": null, | ||
| "difficulty": 2, | ||
| "topics": [ | ||
| "Mathematics", |
There was a problem hiding this comment.
will any other exercise have this topic? if so, I'd like to see it added to them as well. If not, I'm not finding it particularly useful
| sub, | ||
| div) where | ||
|
|
||
| import Prelude hiding (div, abs) -- you have to redifine this two functions |
There was a problem hiding this comment.
I don't think the comment is necessary since we did not use it in any other exercise that has hiding, but if it is, it would have to be spelled "redefine these two functions"
| import Prelude hiding (div, abs) -- you have to redifine this two functions | ||
|
|
||
| -- Data definition ------------------------------------------------------------- | ||
| data Complex = Complex Float Float deriving (Eq, Show) |
There was a problem hiding this comment.
I would not put this here, because students might think they are not allowed to change it. I would like to let the students have their creativity, to choose what they like. So, this line would probably have to be data Complex = Dummy deriving (Eq, Show). Maybe even data Complex = Dummy if we can get away with it.
There was a problem hiding this comment.
But what will happen if someone uses a definition like data Complex = Complex double double I think that would be ok, but the tests wouldn't work. I think.
There was a problem hiding this comment.
That's true. You could look at https://github.com/exercism/haskell/blob/master/exercises/space-age/test/Tests.hs if you want help with that, I suppose. There are example https://github.com/exercism/haskell/blob/master/exercises/space-age/examples/success-double/src/SpaceAge.hs which uses doubles and https://github.com/exercism/haskell/blob/master/exercises/space-age/examples/success-rational/src/SpaceAge.hs which uses rational - both compile with those tests. You could possibly do something similar.
| testC f CaseC{..} = it descriptionC $ f number1C `shouldBe` expectedC | ||
|
|
||
|
|
||
| data CaseA = CaseA { descriptionA :: String |
There was a problem hiding this comment.
Possible to have more descriptive names than A, B, C?
BinOp, UnOp, Scalar?
There was a problem hiding this comment.
Could, be. Don't know if it is worth with something this simple.
| , number1B = Complex 0 5 | ||
| , expectedB = Complex 0 (-5) | ||
| } | ||
| , CaseB { descriptionB = "Conjugate a number with real and imaginary part" |
There was a problem hiding this comment.
extra space between "and" and "imaginary"
| @@ -0,0 +1 @@ | |||
| # Pls regenerate this | |||
There was a problem hiding this comment.
a reminder to myself to regenerate it before merging.
|
Don't really know why it fails. When I run |
Why not? Will you explain what part of https://travis-ci.org/exercism/haskell/jobs/286216812 you did not understand?
So that means the example is good.
Then you should read what https://travis-ci.org/exercism/haskell/jobs/286216812 says, and/or run As you can see, Travis says Indeed, there is no such data constructor, since it's So, how about a Also, you're probably wondering why I didn't just tell you to do this at the same time as changing to It's because I forgot about it. Sorry for my bad memory. |
| testC f CaseC{..} = it descriptionC $ f number1C `shouldBe` fromInteger expectedC | ||
|
|
||
|
|
||
| data CaseA = CaseA { descriptionA :: String |
|
@petertseng Maybe it was fine as it was before. Cause you say that a function But on this section of code: real :: Complex -> Float
real = error "You need to implement this function"
imaginary :: Complex -> Float
imaginary = error "You need to implement this function"It was already kind of implicit the I believe. |
|
an interesting question will then be whether it makes sense to let it be a parameterized type, such as https://hackage.haskell.org/package/base/docs/Data-Complex.html has |
|
You mean |
You can choose what goes in the example. What you said is a possibility.
I still think it should be |
|
But if I leave the |
So have a function that creates a |
| -- binary operators ------------------------------------------------------------ | ||
| mul :: Complex -> Complex -> Complex | ||
| complex :: (a, a) -> Complex a | ||
| complex (a, b) = Complex a b |
There was a problem hiding this comment.
What about complex = curry Complex ?
Oh sorry, that needs to be complex = uncurry Complex, get them mixed up too often.
There was a problem hiding this comment.
Forgot about that. I don't use neither of them too often.
|
|
||
| -- binary operators ------------------------------------------------------------ | ||
| mul :: Complex -> Complex -> Complex | ||
| complex :: (a, a) -> Complex a |
There was a problem hiding this comment.
I wouldn't put this in binary operators section. Binary operator implies Complex a -> Complex a -> something. This complex creates a complex number.
There was a problem hiding this comment.
Binary operator implies two arguments. But I see what you mean.
|
I think it is good now after I regenerate the README. I may need some days to do it. |
|
Untill them, then. |
petertseng
left a comment
There was a problem hiding this comment.
As you can see, I generated the README. I also made two other changes that I might have considered asking you to make, but I had already made you wait too longer:
- After using the
complexfunction, no longer any need to exportComplex(..), justComplex. - The files shouldn't be executable, but they all were. Let's not do that for the next PR.
|
All right, thanks for your fourth exercise contribution! |
Don't really understand what you mean with that. Also your last commit appears to have zero changes. |
I don't see any commit with no changes. I see my last commit is f44dd15 but there are changes, all modes changed from 100755 to 100644 (meaning I made them no longer executable). |
Right didn't see that. My bad. |
| "topics": [ | ||
| ] | ||
| }, | ||
| { |
There was a problem hiding this comment.
note: check whether g is OK for uuid
There was a problem hiding this comment.
AFAIK UUID is usually 16 byte written in hexadecimal notation and separated into 5 groups. So it doesn't look like a valid UUID to me.
Wikipedia: (https://en.wikipedia.org/wiki/Universally_unique_identifier#Format)
In its canonical textual representation, the sixteen octets of a UUID are represented as 32 hexadecimal (base 16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens).
There was a problem hiding this comment.
Has this UUID been generated by configlet?
There was a problem hiding this comment.
I've opened a bug in the configlet repo.
Wether generated or not, at least the linter should have complained:
There was a problem hiding this comment.
@NobbZ It wasn't generated by configlet, my bad there. Also you might want to specify in the issue that it has already been fixed the UUID of this repo.
No description provided.