XTypeOperators extension doesn't work as pragma

后端 未结 3 746
清酒与你
清酒与你 2021-02-19 08:10

I\'m using GHCi 7.0.3 with the following program that implements type-level list:

{-# LANGUAGE TypeOperators #-}

data True
data False

-- List
data Nil
data Con         


        
3条回答
  •  面向向阳花
    2021-02-19 08:21

    Your pragma is correct; the problem is that you're trying to use it from within GHCi, which doesn't inherit the extensions of the loaded module,1 but does pass the options it's given to GHC to compile the files you list (which is why it has the same effect as the pragma).

    You should keep the pragma, and either pass -XTypeOperators when you start GHCi, or enable it after loading the file as follows:

    GHCi> :set -XTypeOperators
    

    1 Which could be very undesirable, and probably impossible in many cases, for e.g. loading compiled modules.

提交回复
热议问题