Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
module Main exposing (main)
import Element exposing (..)
import Html exposing (Html)
foo =
(+) 3 << (+) 2
applicative maybeValue maybeCallback =
case maybeCallback of
Just callback ->
case maybeValue of
Just value ->
Just (callback value)
Nothing ->
Nothing
Nothing ->
Nothing
applicative_v2 =
Maybe.map2 (|>)
main : Html msg
main =
layout [ padding 10 ] <|
column [ spacing 10 ]
[ text "> Maybe.map ((+)3) (Just 2)"
, text <| toString <| Maybe.map ((+) 3) (Just 2)
, text "> Maybe.map ((+)3) Nothing"
, text <| toString <| Maybe.map ((+) 3) Nothing
, text "> foo = (+)3 << (+)2"
, text "> foo 10"
, text <| toString <| foo 10
, text "> applicative maybeValue maybeCallback = \\"
, text " case maybeCallback of \\"
, text " Just callback -> case maybeValue of \\"
, text " Just value -> Just (callback value) \\"
, text " Nothing -> Nothing \\"
, text " Nothing -> Nothing"
, text "> Just ((+)3) |> applicative (Just 2)"
, text <| toString <| (Just ((+) 3) |> applicative (Just 2))
, text "> applicative_v2 = Maybe.map2 (|>)"
, text "> Just ((+)3) |> applicative_v2 (Just 2)"
, text <| toString <| (Just ((+) 3) |> applicative_v2 (Just 2))
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment