diff --git a/extra/recipes/recipes.factor b/extra/recipes/recipes.factor index bccabdc0cf..71d2c41524 100644 --- a/extra/recipes/recipes.factor +++ b/extra/recipes/recipes.factor @@ -39,9 +39,9 @@ STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { ->% 1 :> search submit ok [ [ drop ] ] <$ 2array [ drop ] >>value :> quot viewed 0 [ + ] search ok t "all" ALL -> - tbl selected-value>> votes [ [ + ] curry change-votes modify-tuple ] 2$>-| + tbl selected-value>> votes [ [ + ] curry change-votes modify-tuple ] 2$> 4array - [ drop [ f ] [ "%" dup surround ] if-empty top-recipes ] 3fmap-| :> updates + [ drop [ f ] [ "%" dup surround ] if-empty top-recipes ] 3fmap :> updates updates [ top-genres [ GENRES -> ] map ] bind* [ text>> T{ recipe } swap >>genre get-tuples ] fmap tbl swap updates 2array >>model @@ -52,9 +52,9 @@ STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { [ [ genre>> ] fmap GENRE ->% .5 ] [ [ txt>> ] fmap BODY ->% 1 ] } cleave - [ ] 3fmap-| + [ ] 3fmap [ [ 1 ] <$ ] - [ quot ok #1 [ call( recipe -- ) 0 ] 2fmap-& ] bi + [ quot ok #1 [ call( recipe -- ) 0 ] 2fmap ] bi 2array 0 >>model ] with-interface "recipes" open-window ] with-ui ; diff --git a/extra/gui-sudoku/authors.txt b/extra/sudokus/authors.txt similarity index 100% rename from extra/gui-sudoku/authors.txt rename to extra/sudokus/authors.txt diff --git a/extra/gui-sudoku/gui-sudoku.factor b/extra/sudokus/sudokus.factor similarity index 98% rename from extra/gui-sudoku/gui-sudoku.factor rename to extra/sudokus/sudokus.factor index d89b5b2f1a..efc127f2a5 100644 --- a/extra/gui-sudoku/gui-sudoku.factor +++ b/extra/sudokus/sudokus.factor @@ -3,7 +3,7 @@ lists.lazy locals math math.functions math.parser math.ranges models.product monads random sequences sets ui ui.frp.gadgets ui.frp.layout ui.frp.signals ui.gadgets.alerts vectors fry ui.gadgets.labels memoize ; -IN: gui-sudoku +IN: sudokus : row ( index -- row ) 1 + 9 / ceiling ; : col ( index -- col ) 9 mod 1 + ; diff --git a/extra/gui-sudoku/summary.txt b/extra/sudokus/summary.txt similarity index 100% rename from extra/gui-sudoku/summary.txt rename to extra/sudokus/summary.txt diff --git a/extra/ui/frp/functors/authors.txt b/extra/ui/frp/functors/authors.txt deleted file mode 100644 index 2300f69f11..0000000000 --- a/extra/ui/frp/functors/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Sam Anklesaria diff --git a/extra/ui/frp/functors/functors-docs.factor b/extra/ui/frp/functors/functors-docs.factor deleted file mode 100644 index 256be95702..0000000000 --- a/extra/ui/frp/functors/functors-docs.factor +++ /dev/null @@ -1,10 +0,0 @@ -USING: help.markup help.syntax ui.frp.signals ; -IN: ui.frp.functors - -ARTICLE: { "ui.frp.functors" "signal-collection" } "Signal Collection" -"While " { $vocab-link "models.arrow.smart" } " use arrows and products to apply a quotation to the values of more than one signal, frp has more than one kind of arrow, as well as more than one kind of product" $nl -"A simple pattern is used to generate the requisite 'smart mapping' functions: " -"if 'word' maps a function on a model, then '2word; would map on two models. " -"The product is specified on the end: '2word-product'. " { $link | } " updates when any of the model it collects updates, while " { $link & } " updates when all dependencies have new values. " -"Examples of collection functions are 2fmap-| and 2$>-&" ; -ABOUT: { "ui.frp.functors" "signal-collection" } \ No newline at end of file diff --git a/extra/ui/frp/functors/functors.factor b/extra/ui/frp/functors/functors.factor deleted file mode 100644 index 1b31151013..0000000000 --- a/extra/ui/frp/functors/functors.factor +++ /dev/null @@ -1,34 +0,0 @@ -USING: fry functors generalizations kernel macros peg peg-lexer -sequences sequences.extras ; -FROM: ui.frp.signals => #1 ; -IN: ui.frp.functors - -FUNCTOR: fmaps ( W P -- ) -W IS ${W} -

IS <${P}> -w-n DEFINES ${W}-n-${P} -w-2 DEFINES 2${W}-${P} -w-3 DEFINES 3${W}-${P} -w-4 DEFINES 4${W}-${P} -w-n* DEFINES ${W}-n-${P}* -w-2* DEFINES 2${W}-${P}* -w-3* DEFINES 3${W}-${P}* -w-4* DEFINES 4${W}-${P}* -WHERE -MACRO: w-n ( int -- quot ) dup '[ [ _ narray

] dip [ _ firstn ] prepend W ] ; -: w-2 ( a b quot -- mapped ) 2 w-n ; inline -: w-3 ( a b c quot -- mapped ) 3 w-n ; inline -: w-4 ( a b c d quot -- mapped ) 4 w-n ; inline -MACRO: w-n* ( int -- quot ) dup '[ [ _ narray

#1 ] dip [ _ firstn ] prepend W ] ; -: w-2* ( a b quot -- mapped ) 2 w-n* ; inline -: w-3* ( a b c quot -- mapped ) 3 w-n* ; inline -: w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline -;FUNCTOR - -ON-BNF: FMAPS: -tokenizer = -token = !("FOR"|";"). -middle = "FOR" => [[ drop ignore ]] -endexpr = ";" => [[ drop ignore ]] -expr = token* middle token* endexpr => [[ first2 combos [ first2 fmaps ] each ignore ]] -;ON-BNF \ No newline at end of file diff --git a/extra/ui/frp/functors/summary.txt b/extra/ui/frp/functors/summary.txt deleted file mode 100644 index 6b4e8d2465..0000000000 --- a/extra/ui/frp/functors/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Used by ui.frp.signals to combine models \ No newline at end of file diff --git a/extra/ui/frp/gadgets/gadgets.factor b/extra/ui/frp/gadgets/gadgets.factor index a1e4480064..a5a16676ef 100644 --- a/extra/ui/frp/gadgets/gadgets.factor +++ b/extra/ui/frp/gadgets/gadgets.factor @@ -67,9 +67,6 @@ IN: accessors M: frp-button text>> children>> first text>> ; IN: ui.frp.gadgets -M: gadget null-val drop f ; -M: table null-val multiple-selection?>> [ V{ } clone ] [ f ] if ; -M: frp-field null-val drop "" ; SINGLETON: gadget-monad INSTANCE: gadget-monad monad diff --git a/extra/ui/frp/layout/layout.factor b/extra/ui/frp/layout/layout.factor index bea2700dc2..88443dc479 100644 --- a/extra/ui/frp/layout/layout.factor +++ b/extra/ui/frp/layout/layout.factor @@ -42,7 +42,7 @@ M: model -> dup , ; : ( gadgets type -- track ) [ t make-layout ] dip swap [ add-layout ] each - swap [ <|> >>model ] unless-empty ; inline + swap [ >>model ] unless-empty ; inline : ( gadgets -- track ) horizontal ; inline : ( gadgets -- track ) vertical ; inline @@ -63,7 +63,7 @@ M: gadget (insert-item) dup parent>> track? [ [ f ] dip (insert-item) ] [ insertion-point [ add-gadget ] keep insert-gadget ] if ; M: layout (insert-item) insertion-point [ add-layout ] keep [ gadget>> insert-gadget ] [ size>> insert-size ] 3bi ; M: model (insert-item) parent>> dup book? [ "No models in books" throw ] - [ dup model>> dup |? [ nip swap add-connection ] [ drop [ 1array <|> ] dip (>>model) ] if ] if ; + [ dup model>> dup collection? [ nip swap add-connection ] [ drop [ 1array ] dip (>>model) ] if ] if ; : insert-item ( item location -- ) [ dup get [ drop ] [ remove-members ] if ] [ on ] [ ] tri [ add-member ] 2keep (insert-item) ; @@ -71,5 +71,4 @@ M: model (insert-item) parent>> dup book? [ "No models in books" throw ] : with-interface ( quot -- ) make* [ insert-items ] with-scope ; inline -M: model >>= [ swap insertion-quot ] curry ; -! Temporary places should be cleared at insertion, not on mention \ No newline at end of file +M: model >>= [ swap insertion-quot ] curry ; \ No newline at end of file diff --git a/extra/ui/frp/signals/signals.factor b/extra/ui/frp/signals/signals.factor index dcb4d3e315..9ba2fc6cd2 100644 --- a/extra/ui/frp/signals/signals.factor +++ b/extra/ui/frp/signals/signals.factor @@ -1,11 +1,8 @@ USING: accessors arrays kernel models models.product monads sequences sequences.extras ; -FROM: models.product => product ; +FROM: syntax => >> ; IN: ui.frp.signals -GENERIC: null-val ( gadget -- model ) -M: model null-val drop f ; - TUPLE: multi-model < model important? ; GENERIC: (model-changed) ( model observer -- ) : ( models kind -- model ) f swap new-model [ [ add-dependency ] curry each ] keep ; @@ -47,9 +44,9 @@ M: fold-model model-activated drop ; dip [ >>base ] [ value>> >>value ] bi ; TUPLE: updater-model < multi-model values updates ; -M: updater-model (model-changed) tuck updates>> = +M: updater-model (model-changed) [ tuck updates>> = [ [ values>> value>> ] keep set-model ] - [ drop ] if ; + [ drop ] if ] keep f swap (>>value) ; : ( values updates -- signal ) [ 2array updater-model ] 2keep [ >>values ] [ >>updates ] bi* ; @@ -61,7 +58,7 @@ M: switch-model (model-changed) 2dup switcher>> = : ( signal1 signal2 -- signal' ) swap [ 2array switch-model ] 2keep [ [ value>> >>value ] [ >>original ] bi ] [ >>switcher ] bi* ; M: switch-model model-activated [ original>> ] keep model-changed ; -: >behavior ( event -- behavior ) t ; +: >behavior ( event -- behavior ) t >>value ; TUPLE: mapped-model < multi-model model quot ; : new-mapped-model ( model quot class -- mapped-model ) [ over 1array ] dip @@ -89,20 +86,14 @@ M: action (model-changed) [ [ value>> ] [ quot>> ] bi* call( a -- b ) ] keep val [ swap add-connection ] 2keep model-changed ; : ( model quot -- action-signal ) [ 1array action ] dip >>quot dup f >>value value>> ; -TUPLE: | < multi-model ; -: <|> ( models -- product ) | ; -GENERIC: models-changed ( product -- ) -M: | models-changed drop ; -M: | model-changed +TUPLE: collection < multi-model ; +: ( models -- product ) collection ; +M: collection (model-changed) nip dup dependencies>> [ value>> ] all? - [ [ dup [ value>> ] product-value swap set-model ] keep models-changed ] + [ dup [ value>> ] product-value swap set-model ] [ drop ] if ; -M: | model-activated dup model-changed ; - -TUPLE: & < | ; -: <&> ( models -- product ) & ; -M: & models-changed dependencies>> [ [ null-val ] keep (>>value) ] each ; +M: collection model-activated dup (model-changed) ; ! for side effects TUPLE: (frp-when) < multi-model quot cond ; @@ -110,9 +101,9 @@ TUPLE: (frp-when) < multi-model quot cond ; M: (frp-when) (model-changed) [ quot>> ] 2keep [ value>> ] [ cond>> ] bi* call( a -- ? ) [ call( model -- ) ] [ 2drop ] if ; -M: model fmap ; -USE: ui.frp.functors -FMAPS: $> <$ fmap FOR & | product ; - ! only used in construction -: with-self ( quot: ( model -- model ) -- model ) [ f dup ] dip call swap [ add-dependency ] keep ; inline \ No newline at end of file +: with-self ( quot: ( model -- model ) -- model ) [ f dup ] dip call swap [ add-dependency ] keep ; inline + +USE: ui.frp.signals.templates +M: model fmap ; +<< { "$>" "<$" "fmap" } [ fmaps ] each >> \ No newline at end of file diff --git a/extra/ui/frp/signals/templates/templates.factor b/extra/ui/frp/signals/templates/templates.factor new file mode 100644 index 0000000000..bb08e03ea3 --- /dev/null +++ b/extra/ui/frp/signals/templates/templates.factor @@ -0,0 +1,23 @@ +USING: kernel sequences functors fry macros generalizations ; +IN: ui.frp.signals.templates +FROM: ui.frp.signals => #1 ; +FUNCTOR: fmaps ( W -- ) +W IS ${W} +w-n DEFINES ${W}-n +w-2 DEFINES 2${W} +w-3 DEFINES 3${W} +w-4 DEFINES 4${W} +w-n* DEFINES ${W}-n* +w-2* DEFINES 2${W}* +w-3* DEFINES 3${W}* +w-4* DEFINES 4${W}* +WHERE +MACRO: w-n ( int -- quot ) dup '[ [ _ narray ] dip [ _ firstn ] prepend W ] ; +: w-2 ( a b quot -- mapped ) 2 w-n ; inline +: w-3 ( a b c quot -- mapped ) 3 w-n ; inline +: w-4 ( a b c d quot -- mapped ) 4 w-n ; inline +MACRO: w-n* ( int -- quot ) dup '[ [ _ narray #1 ] dip [ _ firstn ] prepend W ] ; +: w-2* ( a b quot -- mapped ) 2 w-n* ; inline +: w-3* ( a b c quot -- mapped ) 3 w-n* ; inline +: w-4* ( a b c d quot -- mapped ) 4 w-n* ; inline +;FUNCTOR \ No newline at end of file