-
Notifications
You must be signed in to change notification settings - Fork 17
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 a Quick start section in the README file #38
Add a Quick start section in the README file #38
Conversation
@Vladciobanu Thanks a lot for this contribution! This is really cool! The below is rather a side note which I want to discuss. I wasn't sure where to put these thoughts so I'm writing them here :-) I wonder if we can add a direct reference to the Mealy definition (copy it from the wikipedia or something) somewhere here and show how it corresponds to the type >>> let countingMealy = unfoldMealy (\i x -> ((i, x), i + 1)) 0
>>> run (auto countingMealy <~ source "word")
[(0,'w'),(1,'o'),(2,'r'),(3,'d')] and here we have an implementation of -- | A 'Mealy' machine modeled with explicit state.
unfoldMealy :: (s -> a -> (b, s)) -> s -> Mealy a b
unfoldMealy f = go where
go s = Mealy $ \a -> case f s a of
(b, t) -> (b, go t) Of course the above snippets are related to the simpler representation of Mealy from the original lib: newtype Mealy a b = Mealy { runMealy :: a -> (b, Mealy a b) } In our case we can probably use this but also just provide an example using |
I think this would be a nice addition.
I think this is also a nice idea. We should endeavor to keep the quick start small (just enough to give you the context and most basic examples to get you started with the library), so as long as we can capture this in a quick example or two I think it makes a great fit. There's also the
Also a nice idea. @Vladciobanu @paluh I don't think these additions need to hold up this PR, and could be done in a subsequent one if you'd prefer to handle them @paluh -- unless you'd rather do it, @Vladciobanu. We can iterate on these docs sections :) |
haltOn0 :: Int -> Step Identity Int Int | ||
haltOn0 0 = Halt | ||
haltOn0 n = Emit n $ pureMealy haltOn0 | ||
|
||
scale :: Int -> Step Identity Int Int | ||
scale n = Emit (n `div` 2) $ pureMealy scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For parity with the earlier example, should these two be merged?
scale :: Int -> Step Identity Int Int
scale n
| n == 0 = Halt
| otherwise = Emit (n `div` 2) $ pureMealy scale
as this is introduced as "the same machine as before".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! I changed the examples a bit, using guard
in the monadic version. Does this look better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are comfortable switching to two spaces instead of four in the example (as is done in the do
example above) I'd appreciate that, but otherwise 👍!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave this unmerged to give you a moment to respond to this, but at that point I will go ahead and merge.
@thomashoneyman Should I move the above comment to some separate issue like "Document correspondence of |
If it's something to go in the quick start then I'd like to let @Vladciobanu have a chance to see whether and if he'd like to work that in to his existing content here, but if it's for the |
I think the wikipedia definition would be a great addition to the I also think that more in-depth examples belong in either tests or docs, again, in subsequent PR's. I also added imports to the examples. Mostly because I decided to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this, @Vladciobanu. I think that we should create followup issues or get right into the PRs for the changes that you and @paluh mentioned in this thread. We may need to briefly chat about who is going to do what just to make sure that there isn't any wasted / overlapping work. We could do that in this PR thread or in a chat on Discourse -- whatever y'all prefer :)
Also, once this is merged I will release a new version of the library and push the docs to Pursuit. Then we'll have a nice landing page for |
I propose we create a few issues:
I also propose we add the details that @paluh wrote in his original comment here to the docs issue, as an example of something that would be useful to be added there. |
Sounds good to me! Let’s start there. |
Description of the change
FIxes #33 . I added a simple (pure) example using
Ιdentity
over basic operations over integers and strings.I did not update the changelog since it doesn't affect the code in any way. Should I?
Checklist: