0 | module Test.Chem.Generators
 1 |
 2 | import public Chem
 3 | import public Hedgehog
 4 |
 5 | import Data.Maybe
 6 | import Data.Vect
 7 |
 8 | %default total
 9 |
10 | export
11 | atomicNr : Gen AtomicNr
12 | atomicNr = fromMaybe 1 . refineAtomicNr <$> bits8 (linear 1 118)
13 |
14 | export
15 | massNr : Gen MassNr
16 | massNr = fromMaybe 1 . refineMassNr <$> bits16 (linear 1 511)
17 |
18 | export
19 | abundance : Gen Abundance
20 | abundance =
21 |   fromMaybe 1.0 . refineAbundance <$> double (linear MinAbundanceValue 1.0)
22 |
23 | export
24 | molecularMass : Gen MolecularMass
25 | molecularMass =
26 |   fromMaybe 1.0 . refineMolecularMass <$> double (linear 0 MaxMolecularMass)
27 |
28 | export
29 | molarMass : Gen MolarMass
30 | molarMass =
31 |   fromMaybe 1.0 . refineMolarMass <$> double (linear 0 MaxMolecularMass)
32 |
33 | export
34 | charge : Gen Charge
35 | charge = fromMaybe 0 . refineCharge <$> int8 (linearFrom 0 (-15) 15)
36 |
37 | export
38 | radical : Gen Radical
39 | radical = element [NoRadical, Singlet, Doublet, Triplet]
40 |
41 | export
42 | elem : Gen Elem
43 | elem = fromAtomicNr <$> atomicNr
44 |
45 | export
46 | aromElem : Gen AromElem
47 | aromElem =
48 |   choice
49 |     [ (\e => MkAE e False) <$> elem
50 |     , element
51 |         [ MkAE C True
52 |         , MkAE B True
53 |         , MkAE N True
54 |         , MkAE O True
55 |         , MkAE P True
56 |         , MkAE S True
57 |         , MkAE Se True
58 |         , MkAE As True
59 |         ]
60 |     ]
61 |
62 | export
63 | formula : Gen Formula
64 | formula =
65 |   foldMap (uncurry singleton) <$>
66 |   list (linear 0 20) [| MkPair elem (nat $ linear 0 20) |]
67 |
68 | export
69 | isotope : Gen Isotope
70 | isotope = [| MkI elem (maybe massNr) |]
71 |
72 | export
73 | aromIsotope : Gen AromIsotope
74 | aromIsotope = [| mkAI aromElem (maybe massNr) |]
75 |   where
76 |     mkAI : AromElem -> Maybe MassNr -> AromIsotope
77 |     mkAI (MkAE e a) m = MkAI e m a
78 |
79 | export
80 | bondOrder : Gen BondOrder
81 | bondOrder = element [Single,Dbl,Triple]
82 |