Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9287277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:37:58+00:00 2026-06-18T19:37:58+00:00

I was thinking about writing a browser in haskell. A central data structure will

  • 0

I was thinking about writing a browser in haskell. A central data structure will be a mutable tree representing the document. Apart from using a tree composing entirely of iorefs, is there a better solution?

I am hoping to avoid something like this: data DomNode = DomNode TagName NodeProperties (IORef DomNode) [IORef DomNode] (tag, properties, parent, children)

The problem is that javascript can hold onto references of nodes in the tree, and it can mutate (add children, modify properties) any node it has a reference to, as well as traverse to it’s parent.

Edit:

I realized you would need to use mutable state somehow – because you can hold onto a reference to a node that is deleted from the tree, or moved in the tree. If you referred to the element via something based on the structure of the tree, this reference will be invalid.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:38:00+00:00Added an answer on June 18, 2026 at 7:38 pm

    It is natural for javascript to operate with mutable references, so you’ll have to introduce them sooner or later (not necessarily IORefs, maybe some kind of lookup table living in state monad).

    If most of operations on DOM will be performed from javascript, then it is better to select data structure natural for it.

    Don’t try to use pure data structure only for purity itself. Otherwise you’ll finish with hand-made emulation of RAM 🙂 Your task looks imperative for me, so why not to use all the imperative features haskell provides?

    I don’t think zippers, as Niklas B. suggested, can help you a lot. Usually they have only one “cursor”, where you can mutate. (AFAIK in theory any number of cursors are possible, but in practice it is mostly unusable)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm thinking about writing a small application that will help me mass rename files.
I am thinking about writing a windows service that will turn a certain functionality
I'm thinking about writing a development tool that will support development for Android. I
Is there any standard for defining the structure of microformats? (I'm thinking about writing
I'm thinking about writing a browser plugin, but I don't know any C. Can
I'm thinking about writing an automatic spam protection system (maybe I will write a
I'm thinking about writing a FLAC to ALAC and/or FLAC to AAC converter, probably
I am thinking about writing a plugin for email application. It can be put
As a pet project, I was thinking about writing a program to migrate applications
I'm writing a simplified Pascal parser/interpreter and now I'm thinking about segmentation faults. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.