Don't wanna be here? Send us removal request.
Video
youtube
🦜👀Basic Combinators In Action (I,M,K,KI,C) 🦜👀
0 notes
Video
youtube
🦜Building blocks of combinatory logic, the K, and I combinators
🦜Building blocks of combinatory logic, the K, and I combinators, nicknamed the “Kestrel,” and the “Idiot Bird”.
const K = (x) → (y) → x; const I = (x) → (x);
🦜The kestrel and the idiot
👉A constant function is a function that always returns the same thing, no matter what you give it. The kestrel, or K, is a function that makes constant functions. You give it a value, and it returns a constant function that gives that value.
👉The identity function is a function that evaluates to whatever parameter you pass it.
So I(42)→ 42
K(6)(7)
//→ 6
K(12)(24)
//→ 12
👉This is very interesting. Given two values, we can say that K always returns the first value: K(x)(y) → x (that’s not valid JavaScript, but it’s essentially how it works).
👉Now, an interesting thing happens when we pass functions to each other. Consider K(I). From what we just wrote, K(x)(y)→ x So K(I)(x) → I. Makes sense. Now let’s tack one more invocation on: What is K(I)(x)(y)? If K(I)(x) → I, then K(I)(x)(y) === I(y) which is y. Therefore, K(I)(x)(y) → y: K(I)(6)(7) //→ 7 K(I)(12)(24) //→ 24
👉Given two values, K(I) always returns the second value.
K("primus")("secundus")
//→ "primus"
K(I)("primus")("secundus")
//→ "secundus“
If we are not feeling particularly academic, we can name our functions: const first = K, second = K(I); first("primus")("secundus") //→ "primus" second("primus")("secundus") //→ "secundus“
👉This is very interesting. Given two values, we can say that K always returns the first value, and given two values, K(I) always returns the second value. 💥🚴♀️
0 notes
Video
youtube
☢😺Type Signatures (Hindley Milner) In functional Programming
👉Often functions in JavaScript will include comments that indicate the types of their arguments and return values. There's quite a bit of variance across the community but they often follow the following patterns:
👉Many ML-influenced languages, including Haskell, use a standard method of describing the signatures of their functions. As functional programming becomes more common in Javascript, this style of signatures is slowly becoming almost standard
👉Many ML-influenced languages, including Haskell, use a standard method of describing the signatures of their functions.
👉 As functional programming becomes more common in Javascript, this style of signatures is slowly becoming almost standard
👉 Named Types
👉 Lists of Values
👉 Functions
👉 Currying
👉 Type Variables
👉 Parameterized Types
0 notes
Video
youtube
What is natural transformation in 💥🚴♀️Functional Programming 💥🚴♀️
What is natural transformation in 💥🚴♀️Functional Programming 💥🚴♀️
👉Transformation from category to category is functor (it maps objects to objects and morphisms to morphisms).
Natural transformation is transformation from functor to functor (i.e. it's a morphism in category of functors).
👉A natural transformation is a morphism of functors. That is right: for fix categories C and D, we can regard the functors C → D as the object of a new category, and the arrows between these objects are what we are going to call natural transformations.
👉The arrows of functor categories are called natural transformations. Natural transformations are used in defining monads Let C and D be categories,and let F : C → D and G : C → D be functors from C to D.
🚴♀️The images of F and G are representations of the category C within the category D.
🚴♀️We want to translate the representation F yields onto the representation that G yields.
🚴♀️We want to do so in a way that preserves the structure of the representation that F yields. We translate F(a) onto G(a) and F(b) onto G(b) using arrows in D. Call these arrows τa : F(a) → G(a) and τb : F(b) → G(b).
🚴♀️Transformation from category to category is functor (it maps objects to objects and morphisms to morphisms). Natural transformation is transformation from functor to functor (i.e. it's a morphism in category of functors).
0 notes
Video
youtube
🦜What is ADT and It's types (Sum, Product)🦜
👉What is ADT and It's types (Sum, Product)
In computer programming, especially functional programming and type theory, an algebraic data type is a kind of composite type, i.e., a type formed by combining other types.
Two common classes of algebraic types are:
👉Sum Type
👉Product Type
🤘Sum type
A Sum type is the combination of two types together into another one. It is called sum because the number of possible values in the result type is the sum of the input types.
🤘Product type
Product types allow you to have more than one value in a single structure, at the same time. This includes things like arrays, objects, maps, and sets.
0 notes
Video
youtube
👀👓🕶 👉What is Lens in Functional Programming? 👀👓🕶
👉What is Lens in Functional Programming?
A lens is a composable pair of pure getter and setter functions which focus on a particular field inside an object, and obey a set of axioms known as the lens laws.
👉Think of the object as the whole and the field as the part. The getter takes a whole and returns the part of the object that the lens is focused on.
👉The setter takes a whole, and a value to set the part to, and returns a new whole with the part updated. Unlike a function which simply sets a value into an object’s member field, Lens setters are pure functions:
🤚🤚🤚Why Lens?
👉Lenses allow you to abstract state shape behind getters and setters. Instead of littering your codebase with code that dives deep into the shape of a particular object, import a lens.
👉If you later need to change the state shape, you can do so in the lens, and none of the code that depends on the lens will need to change.
🤚🤚🤚Lens Laws
👉view(lens, set(lens, a, store)) ≡ a — If you set a value into the store, and immediately view the value through the lens, you get the value that was set.
👉set(lens, b, set(lens, a, store)) ≡ set(lens, b, store) — If you set a lens value to a and then immediately set the lens value to b, it's the same as if you'd just set the value to b.
👉set(lens, view(lens, store), store) ≡ store — If you get the lens value from the store, and then immediately set that value back into the store, the value is unchanged.
0 notes
Video
youtube
Functional Programming List Operations
Functional Programming List Operations Methods on the array (aka, "list") prototype, so we would naturally refer to them as array or list operations. 👉 Map(..) 👉 Filter(..) 👉 Reduce() Non-FP List Operations 👉 foreach(..) 👉 some(..) 👉 every() 👉Map : A mapping is a transformation from one value to another value. The map(..) function takes its associated value (an array) and a mapping function (the operator function), and executes the mapping function for each individual value in the array. Finally, it returns a new array with all the newly mapped values in it. 👉Filter: Iterate over list and Filtering in the results that match your criteria, using predicate function and store in a new list. The filter(..) list operation takes a function to decide if each value in the original array should be in the new array or not. This function needs to return true if a value should make it, and false if it should be skipped. A function that returns true/false for this kind of decision making goes by the special name: predicate function. 👉Reduce: A combination/reduction is abstractly defined as taking two values(array list) and making them into one value. The function you pass to reduce(..) to perform the reduction is typically called a reducer. A reducer has a different signature from the mapper and predicate functions we looked at earlier. Reducers primarily receive the current reduction result as well as the next value to reduce it with. The current result at each step of the reduction is often referred to as the accumulator.
0 notes
Video
youtube
An applicative functor is a pointed functor with an ap method
An applicative functor is a pointed functor with an ap method. It allows applying a wrapped function to a wrapped value
👉An applicative, our values are wrapped in a context, just like Functors.
👉 Also, our functions wrapped in a context too!
👉 To apply a function wrapped in a context to a value wrapped in a context: 👉 This is useful if you have two objects, and you want to apply a binary function to their contents.
💣Applicative Laws💣
👉Identity
👉Homomorphism :A homomorphism is just a structure preserving map.
👉Interchange: The interchange law states that it doesn't matter if we choose to lift our function into the left or right side of ap.
👉Composition: Function composition holds when applying inside of containers.
0 notes
Video
youtube
Monads object with "of" and "chain" functions
💥Monads 💥 👉A monad is an object with "of" and "chain" functions. chain is like map except it un-nests the resulting nested object. 👉 A monad is an object with of and chain functions. chain is like map except it un-nests the resulting nested object. 👉 of is also known as return in other functional languages. 👉 Chain is also known as flatmap and bind in other languages. 👉 A monad applies wrapped function that returns wrapped value to the wrapped value. Example : Types are monads 👉Box 👉Either 👉Task 👉List
0 notes
Video
youtube
💥Monoids in functional Programming💥
Why Monoids? 👉 Ensure failsafe combination using monoids
👉Monoids are useful because you can perform ‘safe’ operations with them
👉 A semigroup is not a fail-safe operation. Monoids can take as many values or none, an still returns something by default.
0 notes
Video
youtube
👉Semigroup has a 🙌 concat method👈
A semigroup is a type with a concat method. Semigroups Definition 👉 Semigroups : Semigroups come from abstract algebra and laws and properties that come with this mathematical structure. 👉 The property is called associativity. 👉 If we say 1 + 1 + 1 is the same as 1 + (1 + 1). It does not matter how we group the operations. It will always the same result. That is one property we get from semigroups. Associativity Law if we combine three strings by saying (r + s + t), the operation is associative—it doesn’t matter whether we parenthesize it: ((r + s) + t) or (r + (s + t)).
0 notes
Video
youtube
👉Functor Laws👈 for Functors (identity, Composable)
0 notes
Video
youtube
🙌Lambda in Functional Programming🙌
0 notes
Video
youtube
Category Theory & Category Laws in Functional Programming
0 notes
Video
youtube
🙌Pointed Functor in functional programming 🙌
A pointed functor is really a functor F together with a function of defined for every type a, and sending a value x of type a into a value of(x) of type F a.
The function "of" must be a natural transformation from the identity functor into F. Which means that of applied to a function's value equals of applied to the function's argument and then mapped over the function.
You may have heard of functions such as pure, point, unit, and return. These are various monikers for our of method.
0 notes
Video
youtube
💥♾ EventStream Functor ♾ 💥. EventStream is a reactive programming. Examp...
0 notes
Video
youtube
👉Future Functor is lazy & need fork it to kick it off👈
1 note
·
View note