goldfirere / units

The home of the units Haskell package
94 stars 19 forks source link

export internal types to keep error messages shorter #2

Closed aavogt closed 10 years ago

aavogt commented 10 years ago

See how unreadable type errors are now:

Couldn't match type ‛units-1.1:Data.Dimensions.DimSpec.Reorder
                       d20
                       '['units-1.1:Data.Dimensions.DimSpec.D Gram ('P 'Zero),
                         'units-1.1:Data.Dimensions.DimSpec.D Meter 'Zero,
                         'units-1.1:Data.Dimensions.DimSpec.D Second One]
                     units-1.1:Data.Dimensions.DimSpec.@@- '['units-1.1:Data.Dimensions.DimSpec.D
                                                               Gram ('P 'Zero),
                                                             'units-1.1:Data.Dimensions.DimSpec.D
                                                               Meter 'Zero,
                                                             'units-1.1:Data.Dimensions.DimSpec.D
                                                               Second One]’
              with ‛'['units-1.1:Data.Dimensions.DimSpec.D Gram One,
                      'units-1.1:Data.Dimensions.DimSpec.D Second One]’
The type variable ‛d20’ is ambiguous
goldfirere commented 10 years ago

For better or worse (worse, I think), "good error messages" was not a design goal of mine when putting together this package -- "concise unit declaration" and "concise well-typed code" were. You're not the first to complain, and I will be addressing this in a future release. In the meantime, you can always import Data.Dimensions.Poly or Data.Dimensions.Unsafe to bring more declarations into scope. Thanks for opening this ticket, though!

nushio3 commented 10 years ago

I just found a workaround for this problem.

cabal build  --ghc-options=-dsuppress-module-prefixes

Or directly pass -dsuppress-module-prefixes to ghc .

nushio3 commented 10 years ago

Here are some illustrative comparison of the type error messages without https://gist.github.com/nushio3/52be64531ab4a9b1e02a and with https://gist.github.com/nushio3/11314818 the -dsuppress-module-prefixes option.

Thank you aavogt, for raising your suggestions, I wish this talk show up in google and help the future users that encountered the same problem.