Skip to content

Instantly share code, notes, and snippets.

@txrev319
Created June 2, 2014 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save txrev319/69b87f6279765659cab8 to your computer and use it in GitHub Desktop.
Save txrev319/69b87f6279765659cab8 to your computer and use it in GitHub Desktop.
module Doc.Core where
import Data.Map (Map, lookup, insert)
import Data.Maybe (fromJust)
data Doc = Doc { _tag :: Node, _order :: [Id], _childs :: Map Id Doc }
makeLenses ''Doc
doc__get_child :: Doc -> Id -> Doc
doc__get_child doc id = fromJust (Data.Map.lookup id (childs doc))
doc__set_child :: Doc -> Id -> Doc -> Doc
doc__set_child doc id value = doc { childs = Data.Map.insert id value (childs doc) }
doc_name :: Doc -> String
doc_name d = nodeName (tag d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment