Skip to content

Instantly share code, notes, and snippets.

Maxime Dantec Warry

Block or report user

Report or block Warry

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Warry
Warry / jum-1.svg
Last active Sep 13, 2019
Just use monads
View jum-1.svg
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
unsafe elm json encoder+decoder
View MagicJson.elm
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 Aug 9, 2016
Why do you use `(flip andThen)`?
View pipe.md

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)
View decodeJson.elm
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 Nov 19, 2019
Convert a List of objects into a Dict (≈ Map) using an object's property as key, in a type safe way with ELM
View propMap.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
View gist:1472519278124015ac7d
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>{
}
View gist:829f9e970087567ac64c
### 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 Aug 29, 2015
Runtime Type Checker in JS
View README.md

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 Aug 29, 2015
sbt-we plugin workflow
View stylus-shell.js

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 Dec 22, 2015
Demo of wOOOt api
View demo.wooot.coffee
Todos =
# public properties
list: OOO.observableArray([])
# public methods
counter: OOO.computed ()->
@list.length + " remaining todos"
clear: ()->
@list.remove (_)-> _.done
You can’t perform that action at this time.