Skip to content

Instantly share code, notes, and snippets.

View zwilias's full-sized avatar

Ilias Van Peer zwilias

View GitHub Profile
{- 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
type alias HasAnInt = { foo : Int }
badExample : HasAnInt -> HasAnInt
badExample record =
{ record | foo = toString record.foo }
{- Since we're changing the type, we need to give the correct
type annotation for the new return value
-}
thisWorks : HasAnInt -> { foo : String }
nodeDecoder : Decoder Node
nodeDecoder =
oneOf
[ intNodeDecoder
, stringNodeDecoder
]
intNodeDecoder : Decoder Node
intNodeDecoder =
nodeDecoder : Decoder Node
nodeDecoder =
oneOf
[ intNodeDecoder
, stringNodeDecoder
]
intNodeDecoder : Decoder Node
intNodeDecoder =
type Dict k v
= Empty
| Node Int k v (Dict k v) (Dict k v)
balance : Dict k v -> Dict k v
balance dict =
case dict of
Empty ->
dict
isValidBst : Tree comparable -> Bool
isValidBst tree =
case tree of
Empty ->
True
Node value left right ->
all (\x -> x < value) left
&& all (\x -> x > value) right
&& isValidBst left
module Test exposing (..)
{-| A binary search tree will often look roughly like this.
Every node will either be the `Empty` node, or a node with
a key, a value and left and right children. In this case, we
also have an extra `Int` to keep track of the height, but
that's not relevant to the example at hand.
-}
type Dict k v
= Empty
module Random.Insertion exposing (..)
import Benchmark exposing (..)
import Benchmark.Runner exposing (BenchmarkProgram, program)
import Char
import Dict
import Dict.AVL as AvlDict
import Time exposing (Time)
import Random.Pcg as Random exposing (int, list, Seed)
module Pages.SearchPage.Rest exposing (..)
import Html exposing (..)
import Http
import Json.Decode as JD exposing (..)
import Pages.SearchPage.Types exposing (Model, ImagePic, Msg)
import Json.Decode.Pipeline as JP
import RemoteData
fetchImagePics : Cmd Msg
{
"testStarted": {
"name": "My test suite",
"id": "8f22cce8-c281-456e-a2ef-54a863a0ccdd"
}
}
{
"testStarted": {
"name": "My test",
"parentId": "8f22cce8-c281-456e-a2ef-54a863a0ccdd",