serokell / o-clock

:hourglass: Type-safe time units in Haskell
Mozilla Public License 2.0
49 stars 6 forks source link

Use type aliases inside 'UnitName' instances #23

Open chshersh opened 6 years ago

chshersh commented 6 years ago

It allows to write instances like this:

instance ShowUnit WorkDayUnit where showUnit = "wd"
chshersh commented 6 years ago

Also, maybe we should change ShowUnit name? This type class is used not only in Show instances, but in Read. And if it's named as ShowUnit it means that it shows units while in reality it just contains unit suffix. I propose to use UnitName instead.

chshersh commented 6 years ago

We decided to not go with type class approach because our initial problem wasn't solved by moving to this approach (as @vrom911 discovered). So this approach currently doesn't have any benefits from current one. Thus @vrom911 did only renaming.

chshersh commented 6 years ago

We need to create GHC proposal to allow type family applications inside instancec. cc @int-index

int-index commented 6 years ago

https://ghc.haskell.org/trac/ghc/ticket/13773

chshersh commented 6 years ago

Okay, I can comment there.

chshersh commented 6 years ago

I commented. But people want proposal...