web-dev-qa-db-ja.com

一般的なHaskell演算子の発音可能な名前はありますか?

私は Haskell for Great Good を読んでいますが、Haskell演算子の発音方法がわかりません。彼らは「本当の」名前を持っていますか? ?

たとえば、このような表現をどのように読み上げますか?

Just (+3) <*> Just 9

そんなこと知ってる >>=は「バインド」ですが、他はどうですか? Googleは英数字以外の文字を考慮に入れていないため、効率的な検索を行うのは一種の困難です...

独自の演算子を作成できるため、もちろんすべての演算子に名前を付けることはできませんが、一般的な演算子(たとえば、ApplicativeまたはMonadで定義されている演算子)には名前が必要です。 。

195
Thomas Levesque

ここに私がそれらを発音する方法があります:

 >> = bind 
 >> then 
 *> then 
-> to a-> b:aからb
 <-バインド (>> =に脱糖されるため)
 <$>(f)map 
 <$ map-replace by 0 <$ f: "f map-replace by 0"
 <*> ap(ply) (Control.Monad.apと同じなので)(なし、 "" [空白]と同じ)
。へのパイプ 。 b: "b pipe-to a"
 !!インデックス
!インデックス/厳格 あ! b: "a index b"、foo!x:foo strict x
 <|>または/代替 expr <|> term: "expr or term"
 ++ concat/plus/append 
 [] empty list 
:cons 
 ::タイプ/ as f x :: Int:Int型のf x
\lambda 
 @ as go ll @(l:ls):ll as l cons ls
〜怠け者 go〜(a、b):怠laなペアa、bへ
186
fuz
| sym  | pronunciation                                    |
|------|--------------------------------------------------|
| |    | "such that"                                      |
| <-   | "is drawn from"                                  |
| =    | "is defined to be" / "is defined as"             |
| ::   | "has type" / "of type" / "is of type"            |
| ->   | "a function that takes ... and returns a ..." /  |
|      |                          "function that maps" /  |
|      |                          "is a function from" /  |
|      |                                          "to"    |
| $    | "apply"                                          |
| _    | "whatever"                                       |
| !!   | "index"                                          |
| ++   | "concat"                                         |
| []   | "empty list"                                     |
| :    | "cons"                                           |
| \    | "lambda"                                         |
| =>   | "implies" / "then"                               |
| *>   | "then"                                           |
| <$>  | "fmap" / "dollar cyclops"                        |
| <$   | "map-replace by"                                 |
| <*>  | "ap" / "star cyclops"                            |
| .    | "pipe to" / "compose" / "dot"                    |
| <|>  | "or"                                             |
| @    | "as"                                             |
| ~    | "lazy"                                           |
| <=<  | "left fish"                                      |
39
Bob Ueland

私のお気に入りは「左の魚」 (<= <) と「右の魚」 (> =>) です。これは、モナド演算子の左右のKleisli合成です。生意気な作曲、作曲!

28

私は自由に解答を集めて、非常に単純なhaskellプログラムを作成しました。これは、パターンマッチングによってのみhaskellコードを英語に変換しようとします。 letteratorと呼びます。シンボルを文字に変換するからです

-- letterator

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 ll@(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
8
davidDavidson
+      plus
-      minus (OR negative OR negate for unary use)
*      multiply OR times
/      divide
.      dot OR compose
$      apply OR of
4
Thomas Eding