Skip to content

Instantly share code, notes, and snippets.

@lucamug
Created July 18, 2018 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucamug/d24b18d99686d194373fec83e0b17cf7 to your computer and use it in GitHub Desktop.
Save lucamug/d24b18d99686d194373fec83e0b17cf7 to your computer and use it in GitHub Desktop.
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