-> Data Types (Type and Data constructors)
-> Functions
-> High-order functions
Sum
Product
Exponential
ADT :: Sum Type is represented by logical operator OR
ADT :: Product Type - represented by logical operator AND
a Pair has a value a and b of PitchClass typeADT :: Exponential type -> represents some sort of transformation
Each ADT has its operator for the algebra realization
a | b = |a| + |b|
(a, b) = |a| * |b|
a -> b = |b| ^ |a|
Extra :: Types and their cardinalities
|Void| = 0
|()| = 1
|Bool| = 2
-- Let`s check the cardinalities for ::
type Product = |(Bool, Bool)| = ???
type Sum = |Either Bool Bool| = ???
type Exponential = |(Bool -> Bool)| = ???
Two different types A and B with the same cardinalities are isomorphisms between each other.
Function Composition
(.) :: (b -> c) -> (a -> b) -> a -> c
map :: (a -> b) -> [a] -> [b]
-- maybe a little discussion about map and fmap
... a programmer's job ...
is ! as exciting
as a musician`s job ...
Looks pretty exciting, right?
¿Can they be combined?
¡Claro!
Intervals and chord construction
Can be played
=> harmonic if the two notes sound simultaneously (chords) => melodic if they sound successively (melody)The tertian method (third intervals) is the most common way of chrod creation in western music.
I -> C major = (C, E, G) (Ionian Mode) IV -> F major = (F, A, C) (Lydian Mode) V -> G major = (G, B, D) (Mixolydian Mode)
... so where is the bridge between FP and Music in the context of Haskell programming language?!
Euterpea :: A Haskell library for music creation by Paul Hudak and Donya Quick
http://euterpea.com/ in hackage
playDev 2 $ (note qn (C,4) :: Music Pitch)
playDev 2 $ c 4 qn
1. Play C major chord (C E G) in melodically (:+:)
2. Play C major chord (C E G) in simultaneously (:=:)
(I - IV - V)
But for Blues we need 7ths Sevenths Intervals for each chord
I -> C7 = (C, E, G, B) IV -> F7 = (F, A, C, E) V -> G7 = (G, B, D, F)
| C7 | C7 | C7 | C7 | | F7 | F7 | C7 | C7 | | G7 | F7 | C7 | C7 |So the general rule for X7 chord construction is (1, M3, P5, m7)
"with functional programming I feel like there is also like more a 'let it flow' mindset"
"Good OOP is nothing more then FP in disguise."
"Design patterns are for fill the gap of the OOP abstractions lack."
"With the power paradigm you don`t need any framework for DI."
"In FP it is a common practice to compose and build computation pipelines and defer evaluation until the end."
"In FP it is easy, and expected, to factor out common functionality into generic, reusable components that can be composed each other."
"Data structures just are. They don`t do anything."
A good GROOVE for everyone
Functional programming is amazing!
Making music is a fun!
together = amazing fun!
Gracias | Danke | Dzięki | Thanks
Pinchy: https://www.freepik.com/vipanee