Skip to content

Conversation

@mattfenwick
Copy link
Owner

New combinators

  • update
  • updateStateForKey
  • putStateForKey
  • getStateForKey

Refactoring

  • don't make assumptions about what the state is
    • this requires changes to be made to count and position itemizers,
      because they had been assuming the state to be something. Now
      they just assume the state has a specific key with a value of the
      right type
  • write put<X>, get<X> in terms of update<X>
  • presented value of put<X> and update<X> is now the previous value,
    instead of null
  • pull helper functions out into separate module

Questions

  • effect on performance

new:
 - `update`
 - `updateStateForKey`
 - `putStateForKey`
 - `getStateForKey`

refactor:
 - don't make assumptions about what the state is
   - this requires changes to be made to count and position itemizers,
     because they had been assuming the state to be something.  Now
     they just assume the state has a specific key with a value of the
     right type
 - write `put<X>`, `get<X>` in terms of `update<X>`
 - presented value of `put<X>` and `update<X>` is now the previous value,
   instead of null
 - pull helper functions out into separate module
lib/funcs.js Outdated
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a great name.

@mattfenwick mattfenwick changed the title add new combinators and refactor Make state more flexible Jan 21, 2016
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// s -> Parser e s (m t) a
var putState = F.compose(updateState, F.constF);

@mattfenwick
Copy link
Owner Author

Alternate solution: think of parser in terms of a monad stack. Use one state layer for parse state, one for position counting. If the state needs to be more flexible, then just add more state layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant