]> gitweb.factorcode.org Git - factor.git/commitdiff
kernel: Fix the docs for curry/compose a bit.
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 3 Jun 2017 07:10:06 +0000 (02:10 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 3 Jun 2017 07:10:06 +0000 (02:10 -0500)
core/kernel/kernel-docs.factor
core/kernel/kernel.factor

index f37a851e039815f147919d2dfb66ca2fa5ac1a66..a484139bc0c7fa2c80180ae73067a6fb519ec385 100644 (file)
@@ -1,6 +1,5 @@
 USING: alien arrays classes combinators heaps help.markup help.syntax
-kernel.private layouts math quotations sequences system threads words
-;
+kernel.private layouts math quotations sequences system threads words ;
 IN: kernel
 
 HELP: OBJ-CURRENT-THREAD
@@ -775,9 +774,8 @@ HELP: most
 { $description "If the quotation yields a true value when applied to " { $snippet "x" } " and " { $snippet "y" } ", outputs " { $snippet "x" } ", otherwise outputs " { $snippet "y" } "." } ;
 
 HELP: curry
-{ $values { "obj" object } { "quot" callable } { "curry" curry } }
+{ $values { "obj" object } { "quot" callable } { "curry" curried } }
 { $description "Partial application. Outputs a " { $link callable } " which first pushes " { $snippet "obj" } " and then calls " { $snippet "quot" } "." }
-{ $class-description "The class of objects created by " { $link curry } ". These objects print identically to quotations and implement the sequence protocol, however they only use two cells of storage; a reference to the object and a reference to the underlying quotation." }
 { $notes "Even if " { $snippet "obj" } " is a word, it will be pushed as a literal."
 $nl
 "This operation is efficient and does not copy the quotation." }
@@ -787,8 +785,13 @@ $nl
     { $example "USING: kernel math prettyprint sequences ;" "{ 1 2 3 } 2 [ - ] curry map ." "{ -1 0 1 }" }
 } ;
 
+HELP: curried
+{ $class-description "The class of objects created by " { $link curry } ". These objects print identically to quotations and implement the sequence protocol, however they only use two cells of storage; a reference to the object and a reference to the underlying quotation." } ;
+
+{ curry curried compose prepose composed } related-words
+
 HELP: 2curry
-{ $values { "obj1" object } { "obj2" object } { "quot" callable } { "curry" curry } }
+{ $values { "obj1" object } { "obj2" object } { "quot" callable } { "curry" curried } }
 { $description "Outputs a " { $link callable } " which pushes " { $snippet "obj1" } " and " { $snippet "obj2" } " and then calls " { $snippet "quot" } "." }
 { $notes "This operation is efficient and does not copy the quotation." }
 { $examples
@@ -796,12 +799,12 @@ HELP: 2curry
 } ;
 
 HELP: 3curry
-{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quot" callable } { "curry" curry } }
+{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quot" callable } { "curry" curried } }
 { $description "Outputs a " { $link callable } " which pushes " { $snippet "obj1" } ", " { $snippet "obj2" } " and " { $snippet "obj3" } ", and then calls " { $snippet "quot" } "." }
 { $notes "This operation is efficient and does not copy the quotation." } ;
 
 HELP: with
-{ $values { "param" object } { "obj" object } { "quot" { $quotation ( param elt -- ... ) } } { "curry" curry } }
+{ $values { "param" object } { "obj" object } { "quot" { $quotation ( param elt -- ... ) } } { "curry" curried } }
 { $description "Partial application on the left. The following two lines are equivalent:"
     { $code "swap [ swap A ] curry B" }
     { $code "[ A ] with B" }
@@ -819,12 +822,12 @@ HELP: 2with
   { "param2" object }
   { "obj" object }
   { "quot" { $quotation ( param1 param2 elt -- ... ) } }
-  { "curry" curry }
+  { "curry" curried }
 }
 { $description "Partial application on the left of two parameters." } ;
 
 HELP: compose
-{ $values { "quot1" callable } { "quot2" callable } { "compose" compose } }
+{ $values { "quot1" callable } { "quot2" callable } { "compose" composed } }
 { $description "Quotation composition. Outputs a " { $link callable } " which calls " { $snippet "quot1" } " followed by " { $snippet "quot2" } "." }
 { $notes
     "The following two lines are equivalent:"
@@ -835,13 +838,13 @@ HELP: compose
     "However, " { $link compose } " runs in constant time, and the optimizing compiler is able to compile code which calls composed quotations."
 } ;
 
-
 HELP: prepose
-{ $values { "quot1" callable } { "quot2" callable } { "compose" compose } }
+{ $values { "quot1" callable } { "quot2" callable } { "compose" composed } }
 { $description "Quotation composition. Outputs a " { $link callable } " which calls " { $snippet "quot2" } " followed by " { $snippet "quot1" } "." }
 { $notes "See " { $link compose } " for details." } ;
 
-{ compose prepose } related-words
+HELP: composed
+{ $class-description "The class of objects created by " { $link compose } ". These objects print identically to quotations and implement the sequence protocol, however they only use two cells of storage; references to the first and second underlying quotations." } ;
 
 HELP: dip
 { $values { "x" object } { "quot" quotation } }
@@ -943,6 +946,20 @@ $nl
     -rot
 } ;
 
+ARTICLE: "callables" "Callables"
+"Aside from " { $link "quotations" } ", there are two other callables that efficiently combine computations."
+$nl
+"Currying an object onto a quotation:"
+{ $subsections
+    curry
+    curried
+}
+"Composing two quotations:"
+{ $subsections
+    compose
+    composed
+} ;
+
 ARTICLE: "shuffle-words" "Shuffle words"
 "Shuffle words rearrange items at the top of the data stack as indicated by their stack effects. They provide simple data flow control between words. More complex data flow control is available with the " { $link "dataflow-combinators" } " and with " { $link "locals" } "."
 $nl
index 8e3158bde86a0ac74a633bf4145fcf1e346b2b60..d5c7cfb231567cb51f1f8b99057a3a9acd01feb0 100644 (file)
@@ -178,19 +178,19 @@ DEFER: if
     dup dup 2tri* ; inline
 
 ! Quotation building
-: 2curry ( obj1 obj2 quot -- curry )
+: 2curry ( obj1 obj2 quot -- curried )
     curry curry ; inline
 
-: 3curry ( obj1 obj2 obj3 quot -- curry )
+: 3curry ( obj1 obj2 obj3 quot -- curried )
     curry curry curry ; inline
 
-: with ( param obj quot -- obj curry )
+: with ( param obj quot -- obj curried )
     swapd [ swapd call ] 2curry ; inline
 
-: 2with ( param1 param2 obj quot -- obj curry )
+: 2with ( param1 param2 obj quot -- obj curried )
     with with ; inline
 
-: prepose ( quot1 quot2 -- compose )
+: prepose ( quot1 quot2 -- composed )
     swap compose ; inline
 
 ! Curried cleavers