Code Snippets Elm

Short texts Elm 🧑‍💻 Code snippets Elm ✍️ Reading lists Elm 👀

Elm Client, Node Server , Mongo DB, Mongoose ODM – Get Users and Post User

import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (..) import Http import Json.Decode as Decode import Json.Encode as Encode main = Html.program { init = init , view = view , update = update , subscriptions = subscriptions } — MODEL type alias User = { id : String , name : […]

homework.elm

–contruct api url– apiUrl: String -> String -> String -> String apiUrl resource action args = “https://api.example.com/” ++ resource ++ “/” ++ action ++ “?” ++ argsapiUrlWithResource : String -> String apiUrlWithResource = apiUrl “calgary”apiUrlResourceWithAction: String -> String apiUrlResourceWithAction = apiUrlWithResouce “airport”–currying with partial application– apiFullUrlWithArgs: String -> StringapiFullUrlWihArgs = apiUrlResourceAction “pictures”apiFullWithArgs2 : String -> […]

WIP Stringify (~= Debug.toString)

module Stringify exposing ( Stringify , toString , int, float, string, unit , list, tuple, triple , lazy , Record, record, field, buildRecord , Union, union, variant0, variant1, variant2, variant3, variant4, buildUnion, Variant , bool, maybe, result ) {-| Combinatorial API to create stringifiers: functions that convert an elm value in a `Debug.toString`-like text representation. […]

Elm 99제 1문

module P01 exposing (solve) solve : List a -> Maybe a solve list = case list of [] -> Nothing [ x ] -> Just x _ :: tl -> solve tl

R01.elm

module R01 exposing (suite) import Expect import Fuzz exposing (int, list, string) import P01 exposing (last) import Test exposing (Test, describe, fuzz, test) suite : Test suite = describe “P01” [ test “Empty list” Expect.equal Nothing (last []) , test “One element” Expect.equal (Just 1) (last [ 1 ]) , test “Many elements” Expect.equal (Just […]