darcs

Patch 143 Remove (unused) lazy parser and document ReadMonads

Title Remove (unused) lazy parser and document ReadMonads
Superseder Nosy List dagit, darcs-users, kowey
Related Issues
Status accepted Assigned To
Milestone

Created on 2010-01-13.16:37:23 by dagit, last changed 2011-05-10.20:35:57 by darcswatch. Tracked on DarcsWatch.

Files
File name Status Uploaded Type Edit Remove
remove-_unused_-lazy-parser-monad.dpatch dagit, 2010-01-13.16:37:22 application/octet-stream
See mailing list archives for discussion on individual patches.
Messages
msg9809 (view) Author: dagit Date: 2010-01-13.16:37:22
This is just a clean up plus some documentation.  We don't use the lazy parser
anymore, and it seems like it would be nice to reduce the amount of code we have.

No functionality is changed so I think it's safe to apply this before the 2.4
release but I'm not in any rush to have this.
Attachments
msg9899 (view) Author: kowey Date: 2010-01-23.11:04:28
I went ahead and pushed these two, but I have some metacomments on the
haddock

Remove (unused) lazy parser monad
---------------------------------

haddock ReadMonads
------------------
> +-- | This module defines our parsing monad.  In the past there have been lazy
> +-- and strict parsers in this module.  Currently we have only the strict
> +-- variant and it is used for parsing patch files.

The historical note seems helpful because it hints at a possible path we
can explore later.

> +-- | 'lex_char' checks if the next space delimited token from
> +-- the input stream matches a specific 'Char'.
> +-- Uses 'Maybe' inside 'ParserM' to handle failed matches, so

> +-- | 'lex_string' fetches the next whitespace delimited token from
> +-- from the input and checks if it matches the 'String' input.
> +-- Uses 'Maybe' inside 'ParserM' to handle failed matches, so
> +-- that it always returns () on success.

> +-- | 'lex_eof' looks for optional spaces followed by the end of input.
> +-- Uses 'Maybe' inside 'ParserM' to handle failed matches, so
> +-- that it always returns () on success.

> +-- | Checks if any of the input 'String's match the next
> +-- space delimited token in the input stream.
> +-- Uses 'Maybe' inside 'ParserM' to handle failed matches,
> +-- on success it returns the matching 'String'.

There seems to be a bit of redundancy/repetition in these comments that
I think we can cut out.

It sounds like we just need one more general comment somewhere that the
parsers can fail, and for these functions that they return () or the
matching 'String' respectively.  Also, it sounds like we could make a
more general statement that the lex_ functions work with
whitespace-delimited tokens.

I think cutting out that redundancy would give these comments more of
a high-level feel.

> +-- | 'my_lex' drops leading spaces and then breaks the string at the
> +-- next space.  Returns 'Nothing' when the string is empty after
> +-- dropping leading spaces, otherwise it returns the first sequence
> +-- of non-spaces and the remainder of the input.

This also seems rather low-level and it seems like it may be implying
too much.

Would something like this be better, or are we saying too little/the
wrong thing?

  'my_lex' returns the next whitespace-delimited token along with the
  remainder of the input.  If there are no more tokens, it fails.
  Here, a token is just a string without whitespace.

> +    -- | Applies a parsing function, that can return 'Nothing',
> +    -- inside the 'ParserM' monad.
>      maybe_work :: (B.ByteString -> Maybe (a, B.ByteString)) -> m (Maybe a)

Perhaps the point isn't that the function can return 'Nothing' -- that's
also true for 'work' -- but that the parsing still continues even if the
function returns Nothing (we carry on as if we had never tried the
function at all).

> +-- | 'parse_strictly' applies the parser functions to a string
> +-- and checks that each parser produced a result as it goes.
> +-- The strictness is in the 'ParserM' instance for 'SM'.

That last remark was helpful for me :-)

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
msg9900 (view) Author: darcswatch Date: 2010-01-23.11:08:49
This patch bundle (with 2 patches) was just applied to the repository http://darcs.net/.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-2006f41e3802107b38e8df41e9dc247699ed946b
msg14278 (view) Author: darcswatch Date: 2011-05-10.20:35:57
This patch bundle (with 2 patches) was just applied to the repository http://darcs.net/reviewed.
This message was brought to you by DarcsWatch
http://darcswatch.nomeata.de/repo_http:__darcs.net_reviewed.html#bundle-2006f41e3802107b38e8df41e9dc247699ed946b
History
Date User Action Args
2010-01-13 16:37:23dagitcreate
2010-01-13 16:38:07darcswatchsetdarcswatchurl: http://darcswatch.nomeata.de/repo_http:__darcs.net_.html#bundle-2006f41e3802107b38e8df41e9dc247699ed946b
2010-01-23 11:04:36koweysetnosy: + kowey
messages: + msg9899
2010-01-23 11:08:51darcswatchsetstatus: needs-review -> accepted
messages: + msg9900
2011-05-10 20:35:57darcswatchsetmessages: + msg14278