fimad / prometheus-haskell

Haskell client library for exposing prometheus.io metrics.
84 stars 48 forks source link

Define Eq, Ord and NFData instances for Sample #63

Open alexandervandenbroucke opened 3 years ago

alexandervandenbroucke commented 3 years ago

The Sample data type does not have instances for Eq, Ord and NFData.

The former two type classes are generally useful can can be automatically derived by GHC.

The latter type class is primarily useful when writing tests and benchmarks. The entire definition of the instance fits on two lines:

instance NFData Sample where
  rnf (Sample name labelSet value) = rnf name `seq` rnf labelSet `seq` rnf value
ocharles commented 3 years ago

This seems reasonable to me. Did you run into a situation where you needed these instances?

alexandervandenbroucke commented 3 years ago

Yes, in particular when I was writing some test-cases: