0 | module CyBy.Draw.Internal.Atom
2 | import CyBy.Draw.Internal.Role
3 | import Derive.Prelude
7 | %language ElabReflection
20 | %runElab derive "CDAtom" [Show,Eq]
23 | group : CDAtom -> Maybe AtomGroup
24 | group = label . atom
27 | inAnyGroup : CDAtom -> Bool
28 | inAnyGroup = isJust . group
32 | setGroup : AtomGroup -> CDAtom -> CDAtom
33 | setGroup g (CA r a) = CA r $
{label := Just g} a
38 | clearGroup : (group : Nat) -> CDAtom -> CDAtom
39 | clearGroup g (CA r a) = CA r $
{label $= (>>= clear)} a
41 | clear : AtomGroup -> Maybe AtomGroup
42 | clear (G x l) = if x == g then Nothing else (Just $
G x l)
46 | inGroup : Nat -> CDAtom -> Bool
47 | inGroup n (CA _ a) =
50 | Just (G m _) => n == m
57 | Cast CDAtom Role where cast = role
60 | Cast (Adj k b CDAtom) Role where cast = cast . label
63 | Cast (Context k b CDAtom) Role where cast = cast . label
66 | ModRole CDAtom where modRole f = {role $= f}
69 | GetPoint CDAtom where
71 | point = point . position . atom
74 | Cast CDAtom Elem where cast = elem . elem . atom
77 | ModPoint CDAtom where
79 | modPoint f (CA r v) = CA r $
{position $= modPoint f} v