Skip to content

Instantly share code, notes, and snippets.

View Chadtech's full-sized avatar

Chadtech Chadtech

  • SuperFocus.ai
  • Pennsylvania
View GitHub Profile
import Json.Decoder as Json
import Html.Events exposing (keyCode
onEnter : Msg -> Attribute Msg
onEnter msg =
let
isEnterAndShift : CodeAndShift -> Decoder msg
isEnterAndShift {code, shift =
if code == 13 && not shift then
Json.succeed msg
update =
-- ..
let
-- Maybe buildNewMessage and appendNewMessage could live outside this let statement?
-- If not, try giving them a type signature, that helpers outsiders
-- like me understand what this is
buildNewMessage u =
let source =
if u == user
then Self
navItemAttrs : String -> NavigationPoint -> NavigationPoint -> List (Attribute Msg)
navItemAttrs navPointName thisNavPoint currentNavPoint =
let
base =
[ title base
, subtitle ""
, onClick (Navigate thisNavPoint)
]
in
if currentNavPoint == thisNavPoint then
customOnChange : ((Int, String) -> Msg) -> Attribute Msg
customOnChange handler =
let
toTuple =
Json.map2 (,) keyCode targetValue
in
on "input" (Json.map handler toTuple)
mapGrid : (Int -> Int -> Data -> Data) -> Array (Array Data) -> Array (Array Data)
mapGrid f grid =
Array.indexedMap (mapRow f) grid
mapRow : (Int -> Int -> Data -> Data) -> Int -> Array Data -> Array Data
mapRow f rowIndex row =
Array.indexedMap (mapDatum (f rowIndex)) row
mapDatum : (Int -> Data -> Data) -> Int -> Data -> Data
mapDatum f colIndex =
module InfiniteArray exposing ( get )
import Array
get : Int -> Array a -> Maybe a
get index array =
if Array.isEmpty array then
Nothing
else
#
 ##
   #
    #
     ##
       #
        #

Contributing

PRs are welcome. You can expect a response within 5 days.

If you are adding a new function please..

0 Include documentation and make sure it has a code snippet demonstrating what the function does.

1 Give a detailed use case where your function would come in handy.

type Msg
= UpdatePin PinMsg
| SomethingElse
type PinMsg
= This
| That
| OtherThing
import Time exposing (Time)
type alias Model =
{ step : Int
, bpm : Float
, notes : List Float
, playing : Bool
}
type Msg