2 Module : Gargantext.Utils
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Here is a longer description of this module, containing some
11 commentary with @some markup@.
15 module Gargantext.Core.Utils (
16 -- module Gargantext.Utils.Chronos
17 module Gargantext.Core.Utils.Prefix
24 import Data.Char (chr, ord)
27 import Data.Text (Text, pack)
29 import System.Random (initStdGen, uniformR)
31 -- import Gargantext.Utils.Chronos
32 import Gargantext.Core.Utils.Prefix
33 import Gargantext.Prelude
36 something :: Monoid a => Maybe a -> a
37 something Nothing = mempty
38 something (Just a) = a
41 alphanum = (chr <$> digits) <> (chr <$> lowercase) <> (chr <$> uppercase)
43 digits = [(ord '0')..(ord '9')]
44 lowercase = [(ord 'a')..(ord 'z')]
45 uppercase = [(ord 'A')..(ord 'Z')]
47 choices :: Int -> [a] -> IO [a]
51 let (cIdx, _) = uniformR (0, length lst - 1) gen
53 choices' <- choices (num - 1) lst
56 randomString :: Int -> IO Text
58 str <- choices num alphanum