2Copyright (C) 2010 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 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 ) where
34import Text.Printf ( printf )
35import System.Random ( randomIO )
37import Data.Bits ( setBit, clearBit )
38import Control.Monad ( liftM )
40data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
41 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
43instance Show UUID where
44 show (UUID a b c d e f g h i j k l m n o p) =
67getRandomUUID :: IO UUID
69 let getRN :: a -> IO Word8
70 getRN _ = liftM fromIntegral (randomIO :: IO Int)
71 [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] <- mapM getRN ([1..16] :: [Int])
73 let i' = i `setBit` 7 `clearBit` 6
74 -- set version (0100 for random)
75 let g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4
76 return $ UUID a b c d e f g' h i' j k l m n o p
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