Skip to content

Instantly share code, notes, and snippets.

View Warry's full-sized avatar

Maxime Dantec Warry

View GitHub Profile
@Warry
Warry / jum-1.svg
Last active September 13, 2019 19:45
Just use monads
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Warry
Warry / MagicJson.elm
Last active May 31, 2019 12:39
unsafe elm json encoder+decoder
module MagicJson exposing (encode, decode, decoder)
import Json.Encode as Encode exposing (Value)
import Json.Decode as Decode exposing (Decoder)
import Http
encode : a -> Value
encode jsonEncodeElmValue =
@Warry
Warry / pipe.md
Last active August 9, 2016 15:50
Why do you use `(flip andThen)`?

Why do you use (flip andThen)?

TLDR; To use it with the pipe (|>) operator.

The actual andThen problem

Here is the signature for Task.andThen:

import Task exposing (andThen)
module Test where
import Text (asText)
import Array (Array, get)
import Json.Decode (..)
import Maybe (..)
type alias Foo =
{ foo : String
, bar : Bar
@Warry
Warry / propMap.elm
Last active November 19, 2019 04:15
Convert a List of objects into a Dict (≈ Map) using an object's property as key, in a type safe way with ELM
import Dict
-- The transformation function
listToDict : (a -> comparable) -> [a] -> Dict.Dict comparable a
listToDict getKey values = Dict.fromList (map (\v -> (getKey v, v)) values)
-- Demo type
type FooBar =
{ foo : String
, bar : Int
@Warry
Warry / gist:1472519278124015ac7d
Last active August 29, 2015 14:05
this compiles !???
interface Functor<A>{
flatMap<A,B> (f: (A) => B): Functor<B>
}
interface Monad<A> extends Functor<A> {
bind: (A) => Monad<A>
}
interface Option<A> extends Monad<A>{
}
### Keybase proof
I hereby claim:
* I am warry on github.
* I am warry (https://keybase.io/warry) on keybase.
* I have a public key whose fingerprint is E875 F7BA 4FB3 FE3A E55B 8E48 91FA 985A B75E 490A
To claim this, I am signing this object:
@Warry
Warry / README.md
Last active August 29, 2015 14:04
Runtime Type Checker in JS

Runtime Type checker in JS.

is(String, "foo") // true
is(/foo/, "foo") // true
is("foo", "foo") // true

// See test file for more exemples...
@Warry
Warry / stylus-shell.js
Last active August 29, 2015 14:02
sbt-we plugin workflow

We'll take the stylus plugin as an exemple.

Making it work with Node.js

To make our plugin to work with node, we are going to use Christopher's js-transpiler. It allows to develop a shell script that will work independtly on both node and the jvm. You can call a shell script from the cli like this:

    node my-shell.js file.extension '{"flag":true}'

You can use this to debug your processor until it works!

@Warry
Warry / demo.wooot.coffee
Last active December 22, 2015 01:59
Demo of wOOOt api
Todos =
# public properties
list: OOO.observableArray([])
# public methods
counter: OOO.computed ()->
@list.length + " remaining todos"
clear: ()->
@list.remove (_)-> _.done