This file contains hidden or 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
matchOn : String -> String -> Maybe String | |
matchOn start string = | |
if startsWith start string | |
then | |
Just <| dropLeft (length start) string | |
else | |
Nothing |
This file contains hidden or 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
-------------------------- | |
-- CORE LIBRARY IMPORTS -- | |
-------------------------- | |
import Json.Decode as Decode exposing (Decoder, object2, map, string, list, (:=)) | |
import Task exposing (Task, andThen, succeed, fail, onError) | |
import Signal exposing (Signal, Mailbox, mailbox, message, send) | |
import String | |
------------------------- |
This file contains hidden or 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 String exposing (toList) | |
import Maybe | |
import List exposing (member) | |
import Graphics.Element exposing (show) | |
toChar x = | |
if | x == 0 -> '0' | |
| x == 1 -> '1' | |
| x == 2 -> '2' | |
| x == 3 -> '3' |
This file contains hidden or 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 -> List (a -> a) -> a | |
(->>) x list = case list of | |
[] -> x | |
f :: fs -> (->>) (f x) fs |
This file contains hidden or 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
-------------------------- | |
-- CORE LIBRARY IMPORTS -- | |
-------------------------- | |
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn) | |
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2) | |
import Signal exposing (Signal, Mailbox, mailbox, send) | |
import List | |
--------------------------------- | |
-- THIRD PARTY LIBRARY IMPORTS -- |
This file contains hidden or 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
parallel : Address a -> List (Task error a) -> Task error (List ThreadID) | |
parallel address tasks = | |
let | |
sendToAddress task = spawn (task `andThen` send address) | |
in | |
sequence (List.map sendToAddress tasks) |
This file contains hidden or 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
optional : List (Task error value) -> Task error (List value) | |
optional list = case list of | |
[] -> succeed [] | |
task :: tasks -> task | |
`andThen` (\value -> Task.map ((::) value) (optional tasks)) | |
`onError` (\_ -> optional tasks) |
This file contains hidden or 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
/* | |
kill : ThreadID -> Task x () | |
*/ | |
function kill(id){ | |
return asyncFunction(function(callback){ | |
window.clearTimeout(id); | |
callback(succeed(Utils.Tuple0)); | |
}); | |
}; |
This file contains hidden or 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
property : String -> (a -> Bool) -> Arbitrary a -> Property | |
property name predicate arbitrary n seed = | |
let | |
-- failingTestCase' : Seed -> Int -> Trampoline (Result (a, Seed, Int) Int) | |
failingTestCase' seed accum = | |
if accum >= n | |
then | |
Done (Ok n) | |
else | |
let |
This file contains hidden or 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 Lazy.List where | |
import Trampoline exposing (Trampoline(..), trampoline) | |
import Array exposing (Array) | |
import List | |
type LazyListView a | |
= Nil | |
| Cons a (LazyList a) |