1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

Add a Random instance over Ratios.

This commit is contained in:
Rob Rix 2016-06-21 18:48:44 -04:00
parent ce838de9b4
commit 226be486c8
2 changed files with 5 additions and 0 deletions

View File

@ -60,6 +60,7 @@ library
, filepath
, hashable
, mtl
, MonadRandom
, pointed
, QuickCheck >= 2.8.1
, quickcheck-text

View File

@ -1,6 +1,7 @@
module Data.Gram where
import Data.DList
import Control.Monad.Random
import Data.Hashable
import Prologue
@ -15,3 +16,6 @@ type Bag = DList
instance Hashable label => Hashable (Gram label) where
hashWithSalt _ = hash
hash = hash . serialize
instance (Random a, Integral a) => Random (Ratio a) where
random = first (% 1) . random