aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-08-10 15:44:20 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-08-10 15:44:20 -0700
commit6003c596d7b348b29dd4f452f504bfd717634fa2 (patch)
treeeb5b396603e32b29bd8744ed8b310ad46704dea7 /src/Text
parent84e0b905196fae9924c847741c271f40ed57c83f (diff)
downloadpandoc-6003c596d7b348b29dd4f452f504bfd717634fa2.tar.gz
Avoid non-exhaustive pattern match.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/UUID.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs
index c1bae7038..60ff269da 100644
--- a/src/Text/Pandoc/UUID.hs
+++ b/src/Text/Pandoc/UUID.hs
@@ -67,13 +67,14 @@ instance Show UUID where
getUUID :: RandomGen g => g -> UUID
getUUID gen =
- let [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] = take 16 $ randoms gen :: [Word8]
- -- set variant
- i' = i `setBit` 7 `clearBit` 6
- -- set version (0100 for random)
- g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4
- in
- UUID a b c d e f g' h i' j k l m n o p
+ case take 16 (randoms gen :: [Word8]) of
+ [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] ->
+ -- set variant
+ let i' = i `setBit` 7 `clearBit` 6
+ -- set version (0100 for random)
+ g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4
+ in UUID a b c d e f g' h i' j k l m n o p
+ _ -> error "not enough random numbers for UUID" -- should not happen
getRandomUUID :: IO UUID
getRandomUUID = getUUID <$> getStdGen