Talk:GHC.Generics
From HaskellWiki
(Difference between revisions)
| Line 15: | Line 15: | ||
Is it just fallout from of "asymmetry" in Haskell language spec, | Is it just fallout from of "asymmetry" in Haskell language spec, | ||
where Sum types need the pipe to separate the alternations, | where Sum types need the pipe to separate the alternations, | ||
| - | but Product types are written with the factors simply adjacent without a separator? (and then it looks pretty to use infix constructor " | + | but Product types are written with the factors simply adjacent without a separator? (and then it looks pretty to use infix constructor "+351916292294" instead of a prefix constructor "P") |
| + | |||
| + | ---- | ||
| + | |||
| + | Yes, the pipe separates different constructors of a datatype, and the (:*:) is an infix constructor. | ||
| + | |||
| + | --[[User:Dreixel|dreixel]] 17:39, 3 March 2012 (UTC) | ||
Revision as of 17:39, 3 March 2012
Why does the definition of (:+:) use the pipe character "|", but the definition of (:*:) uses the ":*:" operator?
Is that a typo (copied from http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/generic-programming.html), or is there a reason for the difference?
-- | Sums: encode choice between constructors infixr 5 :+: data (:+:) f g p = L1 (f p) | R1 (g p)
-- | Products: encode multiple arguments to constructors infixr 6 :*: data (:*:) f g p = f p :*: g p
Is it just fallout from of "asymmetry" in Haskell language spec,
where Sum types need the pipe to separate the alternations,
but Product types are written with the factors simply adjacent without a separator? (and then it looks pretty to use infix constructor "+351916292294" instead of a prefix constructor "P")
Yes, the pipe separates different constructors of a datatype, and the (:*:) is an infix constructor.
--dreixel 17:39, 3 March 2012 (UTC)
