This file contains hidden or 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
| // Do works with any Monad that implements the fantasy-land spec | |
| // https://github.com/fantasyland/fantasy-land#monad | |
| function Do(Type) { return (a, ...fns) => { | |
| function doIt(as, fns) { | |
| const [fn, ...rest] = fns; | |
| if(rest.length === 0) { | |
| return as['fantasy-land/chain'](a2s => { | |
| return Type['fantasy-land/of'](fn.apply(null, a2s)); | |
| }); | |
| } else { |
This file contains hidden or 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
| alert("Testing") |
This file contains hidden or 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
| // nested chaining is a common occurence for monads: | |
| // type Maybe = Just(a) | Nothing | |
| Just(5) | |
| .chain(num => Just(num * 2) | |
| .chain(num2 => Just(num2 + 3) | |
| .map(num3 => ({num, num2, num3})) | |
| ) |
This file contains hidden or 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
| /** | |
| * ADT | |
| */ | |
| sealed trait MultipleOrOne[A] { | |
| def exists(f: A => Boolean) = | |
| this match { | |
| case Multiple(all) => all.exists(f) | |
| case One(one) => f(one) | |
| } | |
| } |
This file contains hidden or 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 java.util.function.Supplier | |
| import scalaj.http.Http | |
| import scala.concurrent.blocking | |
| import scala.concurrent.Future | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scalaz.concurrent.Task | |
| object AsyncTest { |
This file contains hidden or 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 INVALID = 'INVALID'; | |
| const VALID = 'VALID'; | |
| const Invalid = reasons => ({ | |
| type: INVALID, | |
| reasons: reasons, | |
| and: and, | |
| bifold: bifold | |
| }); |
This file contains hidden or 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
| [{ | |
| "identity":{ | |
| "originator_id":"a9a860ae-7c0f-4c12-a1cf-9fe490ee1f49", | |
| "id":"local-lti-provider" | |
| }, | |
| "original":{ | |
| "timestamp":"2015-01-02T22:17:00.371Z", | |
| "uri":"http://lti-provider.paulgray.net", | |
| "share":true, |
This file contains hidden or 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
| [{ | |
| "identity":{ | |
| "originator_id":"a9a860ae-7c0f-4c12-a1cf-9fe490ee1f49", | |
| "id":"poly-sci-101" | |
| }, | |
| "original":{ | |
| "timestamp":"2015-01-02T22:17:00.371Z", | |
| "uri":"http://study.com/academy/course/political-science-course.html", | |
| "share":true, | |
| "propagate":true, |
This file contains hidden or 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
| { | |
| "recipient":"[email protected]", | |
| "evidence":"http://google.com", | |
| "issued_on":"2012-05-21", | |
| "badge":{ | |
| "version":"1.0.0", | |
| "name":"Explorer", | |
| "image":"http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/2000px-Smiley.svg.png", | |
| "description":"Has displayed expertise in hand-made badge creation.", | |
| "criteria":"http://etec.hawaii.edu", |
This file contains hidden or 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
| /* | |
| Copyright 2015 Viktor Klang | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software |