2Copyright (C) 2010-2016 John MacFarlane <jgm@berkeley.edu>
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 Module : Text.Pandoc.UUID
21 Copyright : Copyright (C) 2010-2016 John MacFarlane
22 License : GNU GPL, version 2 or above
24 Maintainer : John MacFarlane <jgm@berkeley.edu>
26 Portability : portable
28UUID generation using Version 4 (random method) described
29in RFC4122. See http://tools.ietf.org/html/rfc4122
32module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where
34import Data.Bits (clearBit, setBit)
36import System.Random (RandomGen, getStdGen, randoms)
37import Text.Printf (printf)
39data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
40 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
42instance Show UUID where
43 show (UUID a b c d e f g h i j k l m n o p) =
66getUUID :: RandomGen g => g -> UUID
68 let [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] = take 16 $ randoms gen :: [Word8]
70 i' = i `setBit` 7 `clearBit` 6
71 -- set version (0100 for random)
72 g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4
74 UUID a b c d e f g' h i' j k l m n o p
76getRandomUUID :: IO UUID
77getRandomUUID = getUUID <$> getStdGen
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list