5 | import Derive.Prelude
8 | %language ElabReflection
15 | record Isotope where
20 | %runElab derive "Isotope" [Show,Eq]
23 | Cast Isotope Elem where cast = elem
26 | Cast Elem Isotope where cast e = MkI e Nothing
29 | Cast Isotope AromElem where cast (MkI e _) = cast e
32 | Cast AromElem Isotope where cast (MkAE e _) = cast e
35 | HasMolarMass Isotope where
36 | mass (MkI e $
Just m) = maybe (mass e) exactMass (isotopeData e m)
37 | mass (MkI e Nothing) = mass e
39 | exactMass (MkI e $
Just m) = maybe (exactMass e) exactMass (isotopeData e m)
40 | exactMass (MkI e Nothing) = exactMass e
48 | record AromIsotope where
53 | {auto 0 prf : ValidAromatic elem arom}
55 | %runElab derive "AromIsotope" [Show,Eq]
58 | Cast AromIsotope Elem where cast = elem
61 | Cast Elem AromIsotope where cast e = MkAI e Nothing False
64 | Cast AromIsotope AromElem where cast (MkAI e m a) = MkAE e a
67 | Cast AromElem AromIsotope where cast (MkAE e a) = MkAI e Nothing a
70 | Cast AromIsotope Isotope where cast (MkAI e m a) = MkI e m
73 | Cast Isotope AromIsotope where cast (MkI e m) = MkAI e m False
76 | HasMolarMass AromIsotope where
77 | mass (MkAI e (Just m) _) = maybe (mass e) exactMass (isotopeData e m)
78 | mass (MkAI e Nothing _) = mass e
80 | exactMass (MkAI e (Just m) _) = maybe (exactMass e) exactMass (isotopeData e m)
81 | exactMass (MkAI e Nothing _) = exactMass e