Elm Language What does the multiple types in a string (without an arrow) mean in a signature?

In the language of elms, it is difficult for me to explain my question ... In these fragments in elms: I understand the signature in something like

update : Msg -> Model -> Model

where the parameters / output are separated by arrows, but how can I read / do things like:

Sub Msg
Program Never Model Msg

AT:

main : Program Never Model Msg
main =
    program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.none
+4
source share
2 answers

In a type signature, the parameter types are separated ->, with the last type being the return value.

If ->there are no characters , then this is the value of this type. In the example, the maintype mainis equal Program Never Model Msg. It has no arrows, so it does not accept any parameters.

, , main. - , , .

Program Never Model Msg
   |      |     |    |
   |      ------|-----
 type    type parameters

Generics #. # :

void Program<Never, Model, Msg>()

# , , .

Elm guide ,

+10

Sub Msg, List Int, Program Never Model Msg

Sub, List Program . , .

Sub, List Program . , . , .

, of, List of Int s, a Program of Never, Model Msg.

+5

Source: https://habr.com/ru/post/1661111/


All Articles