store
store copied to clipboard
Decidable and Divisible instances for Size
The Size type can implement Divisible:
instance Divisible Size where
divide f = combineSizeWith (fst . f) (snd . f)
conquer = ConstSize 0
I think it can implement Decidable as well, though I'm not sure if my code is correct (or useful):
instance Decidable Size where
choose f s t = VarSize (either (getSizeWith s) (getSizeWith t) . f)
lose f = VarSize (absurd . f)
Interesting! Seems potentially useful, feel free to open a PR. I think the Decidable instance could be useful, for computing the size of the encoding of a sum type.