Haskell Guard Syntax
checkDigit s
| s == '0' = True
| s == '1' = True
| s == '2' = True
| otherwise = False
--Guards in Haskell
myGuards x
| x < 0 = -1
| x > 0 = 1
| otherwise = 0
MultiWayIf Extension Example 1
{-# LANGUAGE MultiWayIf #-}
let s = "/usr/local/file.x"
let ss = case takeExt s of
var | var == "file.x" -> "file.x"
| otherwise -> "nothing"
MultiWayIf Extension Example 2
{-# LANGUAGE MultiWayIf #-}
let s = ":hsc split"
let ss = if | hasPrefix ":run" s -> ""
| hasPrefix ":rep" s -> ""
| hasPrefix ":del" s -> ""
| hasPrefix ":ls" s -> ""
| hasPrefix ":hsc" s -> ""
| otherwise -> s
LambdaCase
-- SEE /Users/aaa/myfile/bitbucket/haskell/redisGet_scr.hs
{-# LANGUAGE LambdaCase #-}
redisSet "k33" "10.12"
:{
n <- redisGet "k33" <&> \case
Just x -> read x :: Double
Nothing -> 0
:}
fw "redisGet \"k33\""
print n