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
-- npm i xhr2 --save | |
import Prelude | |
import Control.Monad.Aff | |
import Control.Monad.Eff.Console | |
import Network.HTTP.Affjax | |
void $ runAff logShow (\x -> log x.response) (get "https://httpbin.org/ip" :: Affjax (console :: CONSOLE) String) | |
void $ runAff logShow (\x -> log (x.response :: String)) (get "https://httpbin.org/ip") |
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
module Main where | |
import Prelude | |
import Control.Monad.Eff.Console | |
import Data.Foldable (foldMap) | |
import TryPureScript | |
type Option a = forall b. (a -> b) -> b -> b |
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
// Testing a service with no dependencies | |
it('description', inject(function(myService) { | |
expect(myService).to.work.dammit; | |
})); | |
// Setting up some test doubles (`dependency` and `dependency2`) | |
it('description2', function() { | |
module({ | |
dependency: { | |
property: 'hello', |
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
// A function that takes an instance of `T` and returns a nullable `T?` | |
fun <T>toNullable(t: T): T? { | |
return t | |
} | |
// If we pass in a `String`, we get back a `String?` | |
val s1 : String? = toNullable("" as String) | |
// So, if we pass in a `String?`, we get back a nested nullable `String??`, right? | |
// Wrong. We get a `String?` |
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
'use strict'; | |
// Usage | |
// node check-markdown-links.js path/to/markdown/file.md | |
// What it does: | |
// - Warns when `[ref][]` or `[title][ref]` style links don't have references defined on a page | |
// - Warns when `[ref]: URL` reference is not used anywhere | |
// - Warns when two `[ref]: URL` references point to same `URL` | |
// - Warns when `[ref]: URL` reference is defined in non-lexical order |
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
{-# LANGUAGE TypeFamilies, FlexibleContexts #-} | |
type Position = (Int, Int) | |
newtype PlayerData = PlayerData { _pos :: Position } | |
data GameStateData = GameStateData PlayerData [Position] | |
-- player typeclass and instance | |
class Player p where |
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
-- start with | |
(+) >>= id $ 2 | |
-- Expand `>>=` using the Monad instance for functions | |
-- instance Monad ((->) r) where | |
-- f >>= k = \ r -> k (f r) r | |
(\r -> id ((+) r) r) $ 2 | |
-- beta reduction | |
id ((+) 2) 2 |
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
/* | |
* useful links | |
* | |
* https://github.com/rickynils/scalacheck/blob/master/doc/UserGuide.md | |
* http://www.scalatest.org/user_guide/generator_driven_property_checks | |
* | |
*/ | |
import org.scalacheck._ | |
import org.scalacheck.Arbitrary._ |
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 monix.execution.Scheduler.Implicits.global | |
import monix.eval._ | |
import io.circe._ | |
import io.circe.generic.semiauto._ | |
import de.heikoseeberger.akkahttpcirce.ErrorAccumulatingCirceSupport._ | |
/** | |
POST localhost:9999/mock | |
{ |
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 shapeless._, record._ | |
import io.circe._ | |
import io.circe.syntax._ | |
import io.circe.generic.encoding._ | |
case class Person(name: String, age: Int) | |
object Person { | |
implicit val encodePerson: Encoder[Person] = | |
ReprObjectEncoder.deriveReprObjectEncoder.contramap { person => |