Added Monoid and Applicative Instances#27
Conversation
Also added utility flatten function
|
This addresses part of #17 |
Data/Matrix.hs
Outdated
There was a problem hiding this comment.
Why not using the monoid instance for Maybe?
fromMaybe mempty $ safeGet row column m <> safeGet row column m'
There was a problem hiding this comment.
Good idea, fixed that
|
Could you make the changes to tests a separate PR? I would like to review that independently. Thanks for contributing! |
|
Do you mean the specific instances or changing the format of them? Because the format is already in this PR #21 I should've added that this one was downstream to that one. |
|
I know you opened that PR, but the changes are in this PR as well. Check the "Files Changed" tab. |
|
I checked the |
|
I think I get what you want. You want me to take the tests out of this and make them their own PR which would be downstream from the other test PR? Perhaps someone smarter than me can attempt to get the quickcheck tests working for applicative, as someone smarter than me told me what the applicative instance should be. There was some talk of a monad instance which I guess would be similar to the applicative instance except flattened twice but that one is a lot harder to test to make sure the monad laws work. I guess it would work similarly to how the list monad works. |
Added Monoid and Applicative Instances
|
Thanks a lot! |
|
np, always happy to contrib |
|
About the monad instance To write a monad instance we will need a function with the same type as flatten: join :: Matrix (Matrix a) -> Matrix aWith the submatrices being allowed to have any size. I don't see a way to implement that in any reasonable way. |
|
This is the error I ran into. I don't think a monad is possible. |
No description provided.