2017-06-21 112 views
4

爲什麼不允許在Haskell中作爲中綴運算符?爲什麼不允許作爲Haskell中綴運算符?

GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help 
Prelude> :{ 
infixr 6 〉 
(〉) :: Int -> (Int -> (Int)) 
a 〉 b = a + 2*b 
:} 
print (1 〉 2) 

根據這一Haskell Reportany Unicode symbol or punctuationthis question它應該工作。

+1

雖然我覺得自己在某個時候嘗試了'>'中綴,但我敢說這只是一個壞主意。允許像'''''','''','''',''''或'''符號定義爲[quasiquote] .1.0/docs/Language-Haskell-TH-Quote.html#t:QuasiQuoter)字符。 – leftaroundabout

回答

6

這可能是一個錯誤。它似乎沒有允許generalCategory標記爲ClosePunctuationOpenPunctuation的任何字符。我建議你在GHC Trac上打開一張票,看看他們的想法。

https://ghc.haskell.org/trac/ghc/ticket/2687看起來相關並且暗示至少在某點OpenPunctuationClosePunctuation被認爲是圖形而不是符號。

相關問題