((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/options" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "egg") (toc)) (section 2 "Rationale" (p "The option datatype is inspired by the equally named type in ML.  It simply stores one or no value at all. To be able to type options, we implement it as a functor, named option-functor, and supply an untyped version as a module named options, which simply applies the functor to a module with an any? type test, i.e. no check at all. This argument module is generated implicitly by instantiation of the functor and named _options.") (section 3 "Usage of the functor to generate a typed options module" (highlight scheme "(require-library datatype)\n(import option-functor datatype)\n\n;; apply functor to instantiate module\n(module item-options = option-functor\n  (import scheme)\n  (define (item? xpr) ...)\n; this defines modules item-options and implicitly _item-options\n\n;; don't forget to patch item-options.import.scm when compiling\nitem-options by replacing the name of the functor parameter with the\nname of the functor argument _item-options\n\n;; import the module\n(import (prefix item-options item-))\n\n;; now use the generated routines")) (section 3 "Usage of the untyped module" (highlight scheme "(use options)")) (section 3 "Generated functions of the options datatype" (section 4 "options" (def (sig (procedure "(options [sym])" (id options))) (p "documentation procedure."))) (section 4 "none" (def (sig (procedure "(none)" (id none))) (p "the fundamental datatype-constructor of an empty option"))) (section 4 "some" (def (sig (procedure "(some item)" (id some))) (p "the fundamental datatype-constructor for a nonempty option. In typed modules, the argument item must pass the item? check."))) (section 4 "option?" (def (sig (procedure "(option? xpr)" (id option?))) (p "type predicate."))) (section 4 "none?" (def (sig (procedure "(none? xpr)" (id none?))) (p "evaluates xpr to an empty option?"))) (section 4 "some-ref" (def (sig (procedure "(some-ref opt)" (id some-ref))) (p "fetches the value out of the option argument, it there is one, otherwise signals an error.")))) (section 3 "Examples" (highlight scheme "(use options)\n\n(define opt (some 5))\n(option? opt) ; -> #t\n(none? opt) ; -> #f\n(none? (none)) ; -> #t\n(some-ref opt) ; -> 5\n(option? (none)) ; -> #t\n(some-ref (none)) ; -> error")) (section 3 "Requirements" (p "datatype"))) (section 2 "Last update" (p "Dec 04, 2017")) (section 2 "Author" (p (int-link "/users/juergen-lorenz" "Juergen Lorenz"))) (section 2 "License" (pre "Copyright (c) 2014-2017, Juergen Lorenz\nAll rights reserved.") (pre "Redistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\nRedistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\nNeither the name of the author nor the names of its contributors may be\nused to endorse or promote products derived from this software without\nspecific prior written permission. \n  \nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\nIS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\nPARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nHOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\nNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")) (section 2 "Version History" (dl (dt "0.3") (dd "patch removed") (dt "0.2") (dd "functor renamed") (dt "0.1") (dd "initial import"))))