haskell-numerics / hmatrix

Linear algebra and numerical computation
381 stars 104 forks source link

base:Internal.Numeric.ComplexOf: turn from type function to type synonym Now it is obvious for GHC that (ComplexOf a) is always a Complex type. #256

Closed thielema closed 6 years ago

idontgetoutmuch commented 6 years ago

I am having trouble understanding the rationale for this; I am guessing it is simpler and would make any future changes easier? It is not clear to me that this is equivalent. I could try writing out the equations myself but perhaps it would be safer if you did it? Apologies for my caution but hmatrix is now used quite widely.

thielema commented 6 years ago

On Fri, 30 Mar 2018, idontgetoutmuch wrote:

I am having trouble understanding the rationale for this; I am guessing it is simpler and would make any future changes easier? It is not clear to me that this is equivalent. I could try writing out the equations myself but perhaps it would be safer if you did it? Apologies for my caution but hmatrix is now used quite widely.

As I can see, ComplexOf is currently not used in hmatrix itself. It could, e.g. be used here:

eigenvalues :: Matrix t -> Vector (ComplexOf t)

But with the current definition of ComplexOf the following would add constraints like (ComplexOf t ~ Complex a) to functions like this one:

cmap realPart . eigenvalues

whereas my new definition of ComplexOf would prevent that.

idontgetoutmuch commented 6 years ago

I am setting up CI so PRs can be accepted with less manual intervention. Hopefully, I will be done in a few days and then I can merge this.

idontgetoutmuch commented 6 years ago

I ran "CI" on it on my fork and it is green: https://circleci.com/gh/idontgetoutmuch/hmatrix/25