Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 517
VELVETDETH Avatar asked Jan 10 '23 11:01

VELVETDETH


1 Answers

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

like image 112
Franky Avatar answered Jan 18 '23 03:01

Franky