我讀編程在Haskell格雷厄姆赫頓和它給在第13章下面的代碼:語法,其中塊
import Control.Applicative
import Data.Char
{- some code omitted -}
newtype Parser a = P (String -> [(a, String)])
item :: Parser Char
item = P (\ input -> case input of
[] -> []
x:xs -> [(x,xs)])
three :: Parser (Char,Char)
three = pure g <*> item <*> item <*> item
where g a b c = (a,c)
我有一個很難理解的最後一行
where g a b c = (a,c)
我知道這行存在,因爲三個類型解析器(Char,Char),但gabc代表什麼? g a b c如何在語法上有效?我已經習慣了看到每個符號x和y在哪裏聲明之前出現在哪裏像案件
f :: s -> (a,s)
f x = y
where y = ... x ...
。