From: Cameron Ball Date: Thu, 12 Mar 2020 16:35:26 +0000 (+0800) Subject: Start wiring up promise example X-Git-Url: http://cameron1729.xyz/?p=fp-lecture.git;a=commitdiff_plain;h=d826eb1edae493831b40bce0bbc67014e21973c0 Start wiring up promise example --- diff --git a/index.html b/index.html index fb60f18..3312a54 100644 --- a/index.html +++ b/index.html @@ -3,8 +3,8 @@ - + href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/default.min.css"> + Crazy Wide-Eyed Functional Programming @@ -125,7 +129,12 @@
=<< The Third Slide >>=
-
Left "Hello" >>= \x -> Right "ah shit"
+
Promise.resolve("We start here")
+    .then(x => Promise.resolve(x + " then get here"))
+    .then(x => Promise.resolve(x + " and finally here!"))
+
Right("We start here")
+    >>= (\x -> Right (x ++ " then get here"))
+    >>= (\x -> Right (x ++ " and finally here!"))
@@ -192,5 +201,24 @@ } })(); + function activateFriends(n) { + f = document.querySelectorAll('.code-friends' + n); + f[0].classList.add("shake-constant"); + f[0].classList.add("shake-slow"); + f[0].classList.add("on"); + f[1].classList.add("shake-constant"); + f[1].classList.add("shake-slow"); + f[1].classList.add("on"); + } + + function deactivateFriends(n) { + f = document.querySelectorAll('.code-friends' + n); + f[0].classList.remove("shake-constant"); + f[0].classList.remove("shake-slow"); + f[0].classList.remove("on"); + f[1].classList.remove("shake-constant"); + f[1].classList.remove("shake-slow"); + f[1].classList.remove("on"); + }