goldfirere / units

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

Question: how to define a typeclass instance on different quantities #48

Closed jcristovao closed 9 years ago

jcristovao commented 9 years ago

Hi, I was porting some old code of mine where I implemented some custom parsers - yes, I am aware of units-parser but it doesn't quite fit my needs - and in this code I was probably abusing the type system for something that is no longer allowed (in 7.10.1). I've converted the types to Units 2.3, but still:

instance ParseUnit Meter (Qu (DimFactorsOf (DimOfUnit Meter)) 'DefaultLCSU Double) where
  parseUnit g = parseUnit' g

Still yields: Illegal type synonym family application in instance: Qu ...

So, how can I declare class instances for quantities like (5 % Second), what should I use for the type?

Thanks

goldfirere commented 9 years ago

See Data.Metrology.TH.evalType for a way to do this. Also see #34 for limitations of the evalType approach.

If you're satisfied with that answer, please close the ticket. Thanks!

jcristovao commented 9 years ago

For my needs its enough, thanks!

jcristovao commented 9 years ago

But by the way, any particular reason v2.3 is not yet on hackage?

goldfirere commented 9 years ago

Oversight? Honestly, I can't remember. But am sorting all of this out now, with a new release of th-desugar to come, according to discussion on #34.

goldfirere commented 9 years ago

units-2.3 released now, including the fix for #34. Thanks for spurring this on.