|>
of course, but also <|
> import String > String.repeat <function: repeat> : Int -> String -> String
> myWrap a = [a] <function> : a -> List a
> String.repeat 2 (myWrap 1)
TypeError: 'undefined' is not a function
-- TYPE MISMATCH
The 2nd argument to function `repeat` is causing a mismatch.
4│ String.repeat 2 (myWrap 1)
^^^^^^^^
Function `repeat` is expecting the 2nd argument to be:
String
But it is:
List number
Hint: I always figure out the type of arguments from left to right. If an
argument is acceptable when I check it, I assume it is "correct" in subsequent
checks. So the problem may actually be in how previous arguments interact with
the 2nd.
type User = Anonymous | LoggedIn String
type Maybe a = Just a | Nothing
type List a = Empty | Node a (List a)
type Tree a = Empty | Node a (Tree a) (Tree a)
{ x = 3, y = 4 }
type alias Person = { first_name : String , last_name : String }
author = Person "Igor" "Kapkov"
author.first_name
{ author | first_name = "Igas" }
> a = 1 1 : number
> b = a + 1 2 : number
> a = 2 2 : number
> b 3 : number
import Graphics.Element exposing (..)
import Mouse
main : Signal Element
main =
Signal.map show Mouse.position
import Graphics.Element exposing (..)
import Mouse
main : Signal Element
main =
Signal.map show countClick
countClick : Signal Int
countClick =
Signal.foldp (\clk count -> count + 1) 0 Mouse.clicks
import Graphics.Element exposing (..) import Mouse main : Signal Element main = Signal.map show lastPositions
lastPositions : Signal (List (Int, Int)) lastPositions = Signal.map (List.take 3) allPositions
allPositions : Signal (List (Int, Int)) allPositions = Signal.foldp (\clk count -> clk :: count) [] positionAfterClick
positionAfterClick : Signal (Int, Int) positionAfterClick = Signal.sampleOn Mouse.clicks Mouse.position
import Html as T
main =
T.ol
[ ]
[ T.li [] [ T.text "hey" ]
, T.li [] [ T.text "ho" ]
]
module CounterApp where
import Counter exposing (update, view)
import StartApp.Simple exposing (start)
main =
start
{ model = 0
, update = update
, view = view
}
module Counter where
import Html exposing (..)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
-- MODEL
type alias Model = Int
-- UPDATE
type Action = Increment | Decrement
update : Action -> Model -> Model
update action model =
case action of
Increment ->
model + 1
Decrement ->
model - 1
-- VIEW
view : Signal.Address Action -> Model -> Html
view address model =
div []
[ button [ onClick address Decrement ] [ text "-" ]
, span [ ] [ text (toString model) ]
, button [ onClick address Increment ] [ text "+" ]
]
$ elm package diff evancz/elm-html 1.0.0 1.1.0
Comparing evancz/elm-html 1.0.0 to 1.1.0...
This is a MINOR change.
------ Changes to module Html.Attributes - MINOR ------
Added:
classList : List (String, Bool) -> Attribute
$ elm package diff evancz/elm-html 1.1.0 2.0.0
Comparing evancz/elm-html 1.1.0 to 2.0.0...
This is a MAJOR change.
------ Changes to module Html.Attributes - MAJOR ------
Added:
attribute : String -> String -> Attribute
minlength : Int -> Attribute
Changed:
- colspan : String -> Attribute
+ colspan : Int -> Attribute
- rowspan : String -> Attribute
+ rowspan : Int -> Attribute
Igor Kapkov, JN Solutions
Slides: igas.me/talks/2016/elm