Opened 7 weeks ago

Last modified 3 weeks ago

#1359 accepted defect

mbox-string's mbox-file->messages does not obviously match its documentation

Reported by: nxg Owned by: iraikov
Priority: major Milestone: someday
Component: unknown Version: 4.12.0
Keywords: mbox typeclass Cc:
Estimated difficulty:

Description

The documentation in module mbox mentions a module mbox-string

[procedure] (mbox-file->messages FILENAME-OR-PORT) => MESSAGE LIST 
Given a filename or port, parses the given file as an mbox database, and returns a list of message objects. The contents of the message are represented as a string.

If, however, I use this in the way that this documentation indicates, it seems to produce errors as illustrated below.

The paragraph before the discussion of mbox-file->messages says 'The procedures in module mbox-string operate on strings.' This seems to contradict the documentation of mbox-file->messages, which claims to operate on filename-or-port, as explicitly opposed to a string.

Incidentally: I cannot deduce from the documentation how one is supposed to use any of mbox, internet-messages abnf or typeclass. Each of the first three points to typeclass for more information, but that documentation doesn't say what 'type-class-style' is (it has only one line of description) and provides an example which doesn't actually seem to use the objects it has set up. This discussion might be a little too concise to be useful. The only further information I could google about 'type-class style' was https://groups.google.com/d/topic/comp.lang.scheme/J2-TpYsMhfY , which appears to lead us back where we started.

% csi

CHICKEN
(c) 2008-2017, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.12.0 (rev 6ea24b6)
macosx-unix-clang-x86-64 [ 64bit manyargs dload ptables ]
compiled 2017-02-19 on yves.more-magic.net (Linux)

#;1> (use mbox-string)
; loading /Data/tools/chicken-4.12/lib/chicken/8/mbox-string.import.so ...
; loading /Data/tools/chicken-4.12/lib/chicken/8/chicken.import.so ...
;;; [...]
; loading /Data/tools/chicken-4.12/lib/chicken/8/mbox.so ...
#;2> (define text (with-input-from-file "test.mbox" read-string))
#;3> text
"From user@somewhere\nReceived: from [12.34.56.78] (nowhere.example.org [12.34.56.78])\n    by 0.0.0.0:587 (trex/5.7.12);\n    Mon, 03 Apr 2017 10:16:04 -0400\nFrom: Test User <testie@example.org>\nTo: someone@example.org\nSubject: Nothing much\nDate: Mon, 03 Apr 2017 15:16:02 +0100\n\nThis is a message for reading.\nIt's quite simple.\n\nAnd on multiple lines.\n"
#;4> (call-with-input-string text mbox-file->messages)

Error: call of non-procedure: #<unspecified>

	Call history:

	<syntax>	  (call-with-input-string text mbox-file->messages)
	<eval>	  (call-with-input-string text mbox-file->messages)	<--
#;4> (call-with-input-file "test.mbox" mbox-file->messages)

Error: call of non-procedure: #<unspecified>

	Call history:

	<syntax>	  (call-with-input-file "test.mbox" mbox-file->messages)
	<eval>	  (call-with-input-file "test.mbox" mbox-file->messages)	<--
#;4> (mbox-file->messages "test.mbox")

Error: call of non-procedure: #<unspecified>

	Call history:

	<syntax>	  (mbox-file->messages "test.mbox")
	<eval>	  (mbox-file->messages "test.mbox")	<--
#;4> 

Change History (3)

comment:1 Changed 7 weeks ago by iraikov

  • Owner set to iraikov
  • Status changed from new to accepted

Hello,

Thanks for trying to use mbox. I think I simply never updated the documentation properly after transitioning to the typeclass interface. I will add more detailed documentation to mbox and the underlying internet-message and abnf interfaces. However, mbox-file->messages takes a file name as an argument, so that should work. I will add support for ports as well.

-Ivan

comment:2 follow-up: Changed 7 weeks ago by nxg

Many thanks, Ivan.

I did try using mbox-file->messages with a file name, which is the last of the failing trials in the transcript. I also tried arguments like (lambda () "test.mbox"), since the error message looked a bit like it was trying to evaluate a void procedure return. But that was a stab in the dark. It's definitely processing the argument in that case, since it produces a file-not-found error if the file doesn't exist. I did look at the mbox source, but with me not understanding the other modules, I wasn't able to get much from that.

Parenthetically: The type-class approach looks very powerful, and I'd like to know more about it. I get the impression it's somewhat similar to Racket's redex https://docs.racket-lang.org/redex/ as an approach (which I also would like to get the time to know more about) -- would that be correct, and if so, I wonder if this would be a possible source of documentation pointers for mbox?

Thanks for your work on the library.

Norman

comment:3 in reply to: ↑ 2 Changed 3 weeks ago by iraikov

As it turned out, the bug was in internet-message, which has a number of mutually-recursive parsers that are all defined in a letrec*. In previous releases of Chicken, the mutually recursive bindings were being resolved properly, but it looks like in the current release some bindings get an undefined value. The trunk version of internet-message should not have this error, and I will soon make a new release.

Replying to nxg:

Many thanks, Ivan.

I did try using mbox-file->messages with a file name, which is the last of the failing trials in the transcript. I also tried arguments like (lambda () "test.mbox"), since the error message looked a bit like it was trying to evaluate a void procedure return. But that was a stab in the dark. It's definitely processing the argument in that case, since it produces a file-not-found error if the file doesn't exist. I did look at the mbox source, but with me not understanding the other modules, I wasn't able to get much from that.

Parenthetically: The type-class approach looks very powerful, and I'd like to know more about it. I get the impression it's somewhat similar to Racket's redex https://docs.racket-lang.org/redex/ as an approach (which I also would like to get the time to know more about) -- would that be correct, and if so, I wonder if this would be a possible source of documentation pointers for mbox?

Thanks for your work on the library.

Norman

Note: See TracTickets for help on using tickets.