This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype Position = (Integer, Integer) | |
data Replacement = { | |
rStart :: Position, | |
rEnd :: Position, | |
rText :: [Char] | |
} | |
data Intersect = BEFORE | INSIDE | AFTER | |
replace :: [Replacement] -> [Char] -> State Position [Char] | |
replace _ [] = return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Types as Sets, containing Values | |
// Union and Intersection Types can be thought as unions and intersections of the underlying Sets | |
// Type Compatibility can be thought of a subset relationship between the underlying Sets | |
// | |
// Usual Set concepts apply, such as: | |
// cardinality (the number of possible values of a given type) | |
// ø (empty set) | |
// unions, intersections, subsets, supersets, sums, products | |
// | |
// Lets look at some types... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let currentScores = { | |
'arg': 0, | |
'mex': 1, | |
'pol': 1, | |
'ara': 3 | |
} | |
function updateScores(scores, {home, away, result}) { | |
scores = {...scores} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const xxx = | |
prK => | |
prV => | |
mapK => | |
mapV => | |
obj => Object.entries(obj).reduce( | |
(obj, [key, value]) => | |
({ | |
...obj, | |
...(prK(key) && prV(value) ? {[mapK(key)]: mapV(value)} : {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Score = Int | |
type Rank = Int | |
climbingLeaderboard :: [Score] -> [Score] -> [Rank] | |
climbingLeaderboard scores alice = let scoreRank = denseRank scores | |
aliceDesc = reverse alice | |
in reverse (rankSeries scoreRank aliceDesc) | |
denseRank :: [Score] -> [(Rank, Score)] | |
denseRank scores = go scores 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Building with Types | |
// Lets imagine we have two types, for example Number and String. | |
// In which ways could we combine them, just one of each, to create a different type? | |
// How could we do this? | |
// Well... we could create an object: | |
type Person = {name: string, age: number}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[profile target-account] | |
role_arn = arn:aws:iam::123456789012:role/RoleInTargetAccount | |
source_profile = instance-role | |
region = eu-central-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Functor3 } from 'fp-ts/lib/Functor' | |
import { IxMonad3 } from 'fp-ts/lib/IxMonad'; | |
declare module 'fp-ts/lib/HKT' { | |
// IxBurgerBuilder :: * -> * -> * -> * | |
interface URI2HKT3<U, L, A> { | |
IxBurgerBuilder: IxBurgerBuilder<U, L, A> | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// getEmptyPlate :: IxBurgerBuilder Ready EmptyPlate BurgerSpec | |
// getEmptyPlate = IxBurgerBuilder mempty | |
const getEmptyPlate = new IxBurgerBuilder<Ready, EmptyPlate, BurgerSpec>([]); | |
// addIngredient :: forall i o. String -> BurgerSpec -> IxBurgerBuilder i o (BurgerSpec) | |
// addIngredient x xs = IxBurgerBuilder $ Ingredient x : xs | |
const addIngredient = <I, O>(s: string) => (spec: BurgerSpec) => new IxBurgerBuilder<I ,O, BurgerSpec>(spec.concat([s])); | |
// -- ADDING THE BUN | |
// placeEmptyBun :: BurgerSpec -> IxBurgerBuilder EmptyPlate BottomBunOn BurgerSpec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- OUR AMAZING INDEXED BURGER SPEC FROM READY TO TOP BUN ON | |
// burgerSpec :: IxBurgerBuilder Ready TopBunOn BurgerSpec | |
// burgerSpec = getEmptyPlate | |
// :>>= placeEmptyBun | |
// :>>= addKetchup | |
// :>>= addPatty | |
// :>>= addCheese | |
// :>>= addOnions | |
// :>>= noLettuce | |
// :>>= addTomato |
NewerOlder