Search code examples
haskellghcaccelerate-haskell

GHC - Infixl declaration in Haskell


Hi I'm building my own version of a GPU programming Haskell DSL which is called Accelerate. The question is about the the infixl declaration:

Here is the code snippet:

infixl 3 :.
data tail :. head = tail :. head
    deriving (Eq, Show)

I think this snippet is quite simple and clear, but when I was trying to load this into ghci, it failed:

It reported:

Illegal declaration of a type or class operator ‘:.’
      Use TypeOperators to declare operators in type and declarations

Do you have any idea about this problem? The ghc version I'm using is:

The Glorious Glasgow Haskell Compilation System, version 7.8.3

Thank you!


Solution

  • You need

    {-# LANGUAGE TypeOperators #-}
    

    in your source file. That is what the error message says. To use them in ghci, you have to enable there as well. See XTypeOperators extension doesn't work as pragma