Created
July 5, 2023 21:35
-
-
Save LSLeary/d26da34d28e9935e71408e40d157bc95 to your computer and use it in GitHub Desktop.
Fancy if-then-else with triangles!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Triangles ((<|), (|>)) where | |
(<|) :: a -> Bool -> Maybe a | |
a <| True = Just a | |
_ <| False = Nothing | |
infix 2 <| | |
(|>) :: Maybe a -> a -> a | |
Just a |> _ = a | |
Nothing |> a = a | |
infix 1 |> | |
_green, _blue :: String | |
_green = "green" <| True |> "blue" | |
_blue = "green" <| False |> "blue" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment