Skip to content

Instantly share code, notes, and snippets.

View zwilias's full-sized avatar

Ilias Van Peer zwilias

View GitHub Profile
companySalaries =
List.foldl
(\datum ->
Dict.update
datum.company
(Maybe.withDefault []
>> (::) datum.monthSalary
>> Just
)
)
module Main where
type Extensible a =
{ count :: Int | a }
data State
= A (Extensible ( text :: String ))
| B (Extensible ( whatever :: String ))
updatePosition :: (forall a. Extensible a -> Extensible a) -> State -> State
@zwilias
zwilias / Exif.elm
Last active July 22, 2019 06:35
Bytes decoder to extract orientation info from EXIF metadata in JPEG images
module Exif exposing (Orientation, orientation)
import Bytes
import Bytes.Decode as Decode exposing (Decoder)
type Orientation
= Normal
| MirrorHorizontal
| Rotate180
'use strict';
require('./index.html');
var Elm = require('./Main.elm');
console.log(Elm);
@zwilias
zwilias / LLRBmap.elm
Created March 13, 2018 20:47
Tail recursive `map` for Dict.LLRB. Slow, but hey, it works.
map : (k -> a -> b) -> Dict k a -> Dict k b
map f dict =
case dict of
Leaf ->
Leaf
Node c k v l r ->
mapHelper f { key = k, color = c, value = f k v, state = Both l r } []

Keybase proof

I hereby claim:

  • I am zwilias on github.
  • I am zwilias (https://keybase.io/zwilias) on keybase.
  • I have a public key ASDRDv6WlRFB1C6K7jeWO0b9OFk8CDT8Z_uswJAFqrkl2go

To claim this, I am signing this object:

module Json.Decode.Completion exposing (..)
import Json.Decode as Decode exposing (Value)
import Json.Encode as Encode
import List.Nonempty as Nonempty exposing (Nonempty(Nonempty))
type alias Errors =
Nonempty Error
@zwilias
zwilias / eliminateRedundantAStar.js
Created October 31, 2017 13:13
Codeshift transformation to eliminate redundant A* calls (i.e. where the number of arguments matches the arity of the function)
module.exports = function(fileInfo, api, options) {
var source = fileInfo.source,
shift = api.jscodeshift,
shiftSource = shift(fileInfo.source);
var functionMakers = ["F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9"];
var functionCallers = ["A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9"];
var arities = {};
shiftSource
module AvlTree exposing (..)
{- Using these definitions, it is impossible to construct an imbalanced binary tree -}
{- a Node encodes a single Node:
- holding a value of type `a`
- with the type of a tree of (height - 1) `t1`
- and the type of a tree of (height - 2) `t2`
-}
{- This is what the runtime passes in -}
type alias UnsafeFlags =
{ browser : Maybe String
, version : Maybe String
, randomSeed : Int
}
{- And this is what we want to work with -}
type alias Flags =
{ browser : String