In Elm-Lang, which means the expression \ _ & # 8594; (symbol, operator, pattern)?

I came across the fact that, in my opinion, was a model in the test code . At first he looked at me as a sample that I had never seen before, but what is it?

I am adding this entry for people who may run into one problem.

+4
source share
2 answers

Actually not a template , but lambda (an anonymous function, function definition not bound to an identifier.), As I was told by megapctr in the elm slack group .

I found this lambda in this context :

unstyledDiv : Test
unstyledDiv =
    let
        input =
            Fixtures.unstyledDiv

        output =
            ""
    in
        describe "unstyled div"
            [ test "pretty prints nothing, because the stylesheet had no properties." <|
                \_ ->
                    prettyPrint input
                        |> Expect.equal (output)
            ]

, , . , (\ _ β†’ "helloWorld" ).

(\_ -> "helloWorld") 5
(\_ -> "helloWorld") 4.0
(\_ -> "helloWorld") "abalone"
(\_ -> "helloWorld") not
(\_ -> "helloWorld") abs

: "helloworld": String

, : "helloworld": String , Int, Float, strong > , .

, , , piped, < |, lambda , : "helloworld"

identity <| (\_ -> "helloWorld") "anything"

: "helloworld": String

,

(identity <| (\_ -> "helloworld" ) "anything") |> String.reverse

: "dlrowolleh": String

, , , , .

\() β†’ statement

/ "No Named Argument Native Type"

lambda, : \() β†’ "hellouniverse"

(\() -> "hellouniverse") ()

: "hellouniverse": String

(identity <| (\() -> "helloworld" ) ()) |> String.reverse

: "esrevinuolleh": String

, (), , , Int Float strong > .

, :

Int, 5

==================================== ERRORS ====================================

-- TYPE MISMATCH --------------------------------------------- repl-temp-000.elm

The argument to this function is causing a mismatch.

4|    \() -> "hellouniverse" ) 5
                               ^
This function is expecting the argument to be:

    ()

But it is:

    number

,

==================================== ERRORS ====================================

-- TYPE MISMATCH --------------------------------------------- repl-temp-000.elm

The argument to this function is causing a mismatch.

4|    \() -> "hellouniverse" ) identity
                               ^^^^^^^^
This function is expecting the argument to be:

    ()

But it is:

    a -> a

. :

:

test x = 
   ((++) "super  "  <|  ( (\() -> "hellouniverse" ) <| x )) |>  String.reverse

,():

test ()

: "esrevinuolleh repus": String

-1

\_ -> - , , , , , \a ->, _.

+7

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


All Articles