https://github.com/ghc/ghc/blob/b4fb232892ec420059e767bbf464bd09361aaefa/lib raries/base/GHC/Base.hs#L973 instance Applicative ((->) a) where pure = const (<*>) f g x = f x (g x) liftA2 q f g x = q (f x) (g x) (<*>) f g x = f x (g x) is S.
concatenative programming language Add in Forth. 2 3 + 1. Put 2 on the stack. 2. Put 3 on the stack. 3. Pop 3 & 2 from the stack, then plus them, put the result 5 on the stack.
concatenative programming language If 3 + evaluated lazily it makes sence. 1. Put 3 on the stack. 2. Pop 3 & another value from the stack, then plus them, put the result ont the stack. concatenative programming language like Factor & Popr do this.
Example 2 : factorial in Factor. : factorial_rec ( n n -- n ) dup 0 = [ drop ] [ [| n m | n m * m 1 - factorial_rec ] call ] if ; : factorial ( n -- n ) dup 0 < [ drop 0 ] [ 1 swap factorial_rec ] if ; 9 factorial [ ] is quotatin. It's evaluated in lazy.
Example 2 : factorial in Popr factorial: [1 == 1 swap !] [dup dup 1 - factorial * swap 1 > !] | pushl head 9 factorial 1 == 1 swap ! fails when the value is greater than 1. dup dup 1 - factorial * swap 1 > ! fails when the value is 1.