Simplify code using pipe operators?

Hi,

This code seems long winded. Can I simplify it?

type alias Model = { page : Page }

– this compiles
initLogin : ( Page, Cmd Msg )
initLogin =
let
( m, c ) =
Login.init
in
( LoginPage m, c |> Cmd.map LoginMsg )

What I want to get to is kind of like

– this does not
Login.init
|> (\m c -> LoginPage m, c |> Cmd.map LoginMsg )

Is this possible?

Thanks for your help!

I think this should compile:

Login.init
|> (\(m, c) -> (LoginPage m, c |> Cmd.map LoginMsg) )

Or

Login.init
|> Tuple.mapBoth LoginPage (Cmd.map LoginMsg)
1 Like

Indeed it does, Thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.