Skip to content

Instantly share code, notes, and snippets.

View maxfarseer's full-sized avatar

Max P maxfarseer

View GitHub Profile
@maxfarseer
maxfarseer / custom.elm
Created November 17, 2019 18:23
Add custom web element & logic (Elm, Canvas, Fabric.js)
-- Main.elm -> добавляем "port"
port module Main exposing (main)
-- ...
-- добавляем команду
port sendDataToJs : String -> Cmd msg
-- update функция
case msg of
@maxfarseer
maxfarseer / asset.elm
Last active November 17, 2019 09:52
Type Image (Asset)
module Asset exposing (Image, src, waterfall)
import Html exposing (Attribute)
import Html.Attributes as Attr
type Image
= Image String
@maxfarseer
maxfarseer / making-impossible-state.elm
Created November 16, 2019 13:37
Making impossible state video
-- Question модуль
module Question exposing ( History(..) )
type History =
History
{ previous : List Question
, current : Question
, remaining : List Question
}
@maxfarseer
maxfarseer / making-impossible-state.elm
Created November 16, 2019 13:24
Making impossible state video
-- zip list структура
-- обернутая в custom type с одним вариантом
type History =
History
{ previous : List Question
, current : Question
, remaining : List Question
}
-- следовательно, для работы придется использовать case
@maxfarseer
maxfarseer / making-impossible-state.elm
Created November 16, 2019 11:29
Making impossible state video
-- было
type alias Stylesheet =
{ declarations: List Declaration }
-- стало
type alias Stylesheet =
{ charset : Maybe String
, imports : List Import
, namespaces : List Namespace
, declarations : List Declaration
@maxfarseer
maxfarseer / eia.elm
Created November 16, 2019 09:21
elm-in-action-29
navLink : Page -> String -> String -> Html msg
@maxfarseer
maxfarseer / eia.elm
Created November 16, 2019 09:20
elm-in-action-28
abc : number1 -> number2 -> numberWtf
@maxfarseer
maxfarseer / eia.elm
Created November 16, 2019 09:19
elm-in-action-27
testSlider : String -> (Int -> Msg) -> (Model -> Int) -> Test
-- То что вернули `Test` - условие примера.
-- SlidNoise = (Int -> Msg),
-- так как SlidNoise **кастомный тип**
-- и в тоже время **функция-контруктор**,
-- которая принимает Int и возвращает Msg).
-- .noise = ( Model -> Int ),
@maxfarseer
maxfarseer / eia.elm
Created November 16, 2019 09:18
elm-in-action-26
Result.map : (a -> b) -> Result x a -> Result x b
@maxfarseer
maxfarseer / eia.elm
Created November 16, 2019 09:17
elm-in-action-25
List.map : (a -> b) -> List a -> List b