Skip to content

Cannot define custom fixity for infix data constructors in GHCi

When compiling from a module, declaring a custom fixity for an infix data constructor is valid:

module DataFixity where

data Infix a b = a :@: b
infixl 4 :@:

And GHCi recognizes this:

$ ghci DataFixity.hs
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling DataFixity       ( DataFixity.hs, interpreted )
Ok, modules loaded: DataFixity.
λ> :i :@:
data Infix a b = a :@: b        -- Defined at DataFixity.hs:3:18
infixl 4 :@:

However, one cannot do this entirely in GHCi:

$ ghci
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> data Infix a b = a :@: b; infixl 4 :@:
λ> :i (:@:)
data Infix a b = a :@: b        -- Defined at <interactive>:2:18

GHCi simply assumes :@: has the default infix precedence.

Trac metadata
Trac field Value
Version 7.8.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC hvr
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information