Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add State Docs #171

Merged
merged 2 commits into from
Jan 1, 2018
Merged

Add State Docs #171

merged 2 commits into from
Jan 1, 2018

Conversation

evilsoft
Copy link
Owner

Much Punk

image

This PR marks off another item from this issue and adds the README for documentation for the src/State bit of code.

@coveralls
Copy link

coveralls commented Dec 31, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 10ff4c9 on state-docs into c110fff on master.

Copy link
Owner Author

@evilsoft evilsoft left a comment

Choose a reason for hiding this comment

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

Make these changes

```haskell
State s a
```
`State` is an Algebraic Data Type that abstracts away state management
Copy link
Owner Author

Choose a reason for hiding this comment

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

Algebraic Data Type that abstracts away state management associated when working with stateful computations

Should be:
Algebraic Data Type that abstracts away the associated state management that comes with stateful computations.

```
`State` is an Algebraic Data Type that abstracts away state management
associated when working with stateful computations.`State` is parameterized by
two types, a state `s` and a resultant `a`. The `a` may vary it's type, but
Copy link
Owner Author

Choose a reason for hiding this comment

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

a may vary it's type

Resultant may vary it's type

`State` is an Algebraic Data Type that abstracts away state management
associated when working with stateful computations.`State` is parameterized by
two types, a state `s` and a resultant `a`. The `a` may vary it's type, but
the `s` must be fixed to a type that is used by all related stateful
Copy link
Owner Author

Choose a reason for hiding this comment

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

the s must be fixed to a type

the state must be fixed to a type

All `State` instances wrap a function of the form `s -> Pair a s` and can be
constructed by providing a function of this form. In order to get maximum
reuse of existing functions, a few construction helpers are available on
`State` constructor.
Copy link
Owner Author

Choose a reason for hiding this comment

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

State constructor.

the State constructor.


`State` is lazy and is required to be run at the edge with some initial state.
Three methods are available on the instance for running the `State` with a
given initial state. `runWith` will return a `Pair a s` with the state `s` on
Copy link
Owner Author

Choose a reason for hiding this comment

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

add on page link to runWith

value to run the instance with. The value must be a member of the type that the
given `State` instance is fixed to in it's state portion, `s`.

`evalWith`, when called with a value, will run the state transition with the
Copy link
Owner Author

Choose a reason for hiding this comment

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

evalWith, when called with a value, will run the state

When called, evalWith will run the state

given `State` instance is fixed to in it's state portion, `s`.

`evalWith`, when called with a value, will run the state transition with the
given value as the initial state and will return the resulting resultant and
Copy link
Owner Author

Choose a reason for hiding this comment

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

return the resulting resultant and will discard the state portion.

return the resulting resultant, discarding the state portion.

value to run the instance with. The value must be a member of the type that the
given `State` instance is fixed to in it's state portion, `s`.

`execWith`, when called with a value, will run the state transition with the
Copy link
Owner Author

Choose a reason for hiding this comment

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

execWith, when called with a value, will run the state

When called, execWith will run the state


`execWith`, when called with a value, will run the state transition with the
given value as the initial state and will return the resulting state and will
discard the resultant portion.
Copy link
Owner Author

Choose a reason for hiding this comment

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

return the resulting state and will discard the resultant portion.

return the resulting state, discarding the resultant portion.


const compose = require('crocks/helpers/compose')
const curry = require('crocks/helpers/curry')
const evalWith = require('crocks/State/evalWith')
Copy link
Owner Author

Choose a reason for hiding this comment

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

move upstairs.

@coveralls
Copy link

coveralls commented Jan 1, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 70ac927 on state-docs into 5cc93fe on master.

@coveralls
Copy link

coveralls commented Jan 1, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling d452d74 on state-docs into 5cc93fe on master.

@evilsoft
Copy link
Owner Author

evilsoft commented Jan 1, 2018

image

@evilsoft evilsoft merged commit b139ed3 into master Jan 1, 2018
@evilsoft evilsoft deleted the state-docs branch January 1, 2018 01:33
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.

2 participants