我冒昧的答案組裝成只有通過模式匹配試圖Haskell代碼翻譯成英文一個非常簡單的Haskell程序。
-- literator
main = translateLn <$> getLine >>= putStrLn
translateLn :: String -> String
translateLn = unwords . map t . words
t :: String -> String -- t(ranslate)
-- historical accurate naming
t "=" = "is equal too" -- The Whetstone of Witte - Robert Recorde (1557)
-- proposed namings
-- src http://stackoverflow.com/a/7747115/1091457
t ">>=" = "bind"
t "*>" = "then"
t "->" = "to" -- a -> b: a to b
t "<$" = "map-replace by" -- 0 <$ f: "f map-replace by 0"
t "<*>" = "ap(ply)" -- (as it is the same as Control.Monad.ap)
t "!!" = "index"
t "!" = "index/strict" -- a ! b: "a index b", foo !x: foo strict x
t "<|>" = "or/alternative" -- expr <|> term: "expr or term"
t "[]" = "empty list"
t ":" = "cons"
t "\\" = "lambda"
t "@" = "as" -- go [email protected](l:ls): go ll as l cons ls
t "~" = "lazy" -- go ~(a,b): go lazy pair a, b
-- t ">>" = "then"
-- t "<-" = "bind" -- (as it desugars to >>=)
-- t "<$>" = "(f)map"
-- t "$" = "" -- (none, just as " " [whitespace])
-- t "." = "pipe to" -- a . b: "b pipe-to a"
-- t "++" = "concat/plus/append"
-- t "::" = "ofType/as" -- f x :: Int: f x of type Int
-- additional names
-- src http://stackoverflow.com/a/16801782/1091457
t "|" = "such that"
t "<-" = "is drawn from"
t "::" = "is of type"
t "_" = "whatever"
t "++" = "append"
t "=>" = "implies"
t "." = "compose"
t "<=<" = "left fish"
-- t "=" = "is defined as"
-- t "<$>" = "(f)map"
-- src http://stackoverflow.com/a/7747149/1091457
t "$" = "of"
-- src http://stackoverflow.com/questions/28471898/colloquial-terms-for-haskell-operators-e-g?noredirect=1&lq=1#comment45268311_28471898
t ">>" = "sequence"
-- t "<$>" = "infix fmap"
-- t ">>=" = "bind"
--------------
-- Examples --
--------------
-- "(:) <$> Just 3 <*> Just [4]"
-- meaning "Cons applied to just three applied to just list with one element four"
t "(:)" = "Cons"
t "Just" = "just"
t "<$>" = "applied to"
t "3" = "three" -- this is might go a bit too far
t "[4]" = "list with one element four" -- this one too, let's just see where this gets us
-- additional expressions to translate from
-- src http://stackoverflow.com/a/21322952/1091457
-- delete (0, 0) $ (,) <$> [-1..1] <*> [-1..1]
-- (,) <$> [-1..1] <*> [-1..1] & delete (0, 0)
-- liftA2 (,) [-1..1] [-1..1] & delete (0, 0)
t "(,)" = "tuple constructor"
t "&" = "then" -- flipped `$`
-- everything not matched until this point stays at it is
t x = x
它是一個很好的問題,我不知道任何答案。也許我們需要一個命名方案,或者圖書館作者應該提供可發音的名字作爲Haddock文檔的一部分。 –
非常好的問題。通常我讀<*>爲「apply」,<$>爲「fmap」。至於其他人,我不知道。 – DuoSRX
這是一個重複的[「哈斯克爾:'<*>'怎麼發音?」](http://stackoverflow.com/questions/3242361/haskell-how-is-pronounced)?即使不是,它的答案也許值得一試。 –