It would be convenient to have an instance of the Random class for Closed.
It is a pretty straightforward lift from Integer's random.
import Data.Type.Ord
import GHC.TypeLits
instance (KnownNat a, KnownNat b, a <= b) => Random (Closed a b) where
randomR (a, b) g =
let (x, g') = randomR (getClosed a, getClosed b) g
in (Closed.unsafeClosed x, g')
random = randomR (minBound, maxBound)
IMO random is common enough package to put it here.
It would be convenient to have an instance of the
Randomclass forClosed.It is a pretty straightforward lift from
Integer's random.IMO
randomis common enough package to put it here.