Opened 2 months ago

Last modified 3 days ago

#15633 patch bug

Type-checker plugins aren't loaded in GHCi 8.6.1

Reported by: phadej Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.6.1-beta1
Keywords: TypeCheckerPlugins Cc: adamgundry
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5348
Wiki Page:

Description

Type-Checker plugins seem to work in GHCi-8.4.3 https://gist.github.com/phadej/f2040eba327a88d3652cda021403f97f

However with GHC-8.6.1

The Glorious Glasgow Haskell Compilation System, version 8.6.0.20180907 76a233143f1ec940f342ce3ce3afaf306923b392 (which seems to be the last commit in 8.6 branch atm)

the plugins aren't loaded.

% ghci-8.6.1 -fplugin=ThereIsNoPlugin
GHCi, version 8.6.0.20180907: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/ogre/.ghci
λ> 

starts a session without a warning. 8.4.3 however fails:

% ghci-8.4.3 -fplugin=ThereIsNoPlugin
GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
<command line>: Could not find module ‘ThereIsNoPlugin’

Change History (6)

comment:1 Changed 2 months ago by phadej

Summary: Type-checker plugins aren't loaded in 8.6.1Type-checker plugins aren't loaded in GHCi 8.6.1

comment:2 Changed 2 months ago by darchon

To elaborate further

Loading:

{-# LANGUAGE DataKinds, TypeOperators #-}
module Test where

import Data.Proxy
import GHC.TypeLits

p1 :: Proxy a -> Proxy b -> Proxy (a + b) -> Proxy (b + a)
p1 _ _ = id

without the normalisation plugin gives:

$ ghci Test.hs
GHCi, version 8.6.0.20180907: http://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/christiaan/devel/clash-compiler/clash-prelude/.ghc.environment.x86_64-linux-8.6.0.20180907
[1 of 1] Compiling Test             ( Test.hs, interpreted )

Test.hs:8:10: error:
    • Couldn't match type ‘a + b’ with ‘b + a’
      Expected type: Proxy (a + b) -> Proxy (b + a)
        Actual type: Proxy (b + a) -> Proxy (b + a)
      NB: ‘+’ is a non-injective type family
    • In the expression: id
      In an equation for ‘p1’: p1 _ _ = id
    • Relevant bindings include
        p1 :: Proxy a -> Proxy b -> Proxy (a + b) -> Proxy (b + a)
          (bound at Test.hs:8:1)
  |
8 | p1 _ _ = id
  |          ^^
Failed, no modules loaded.

and of course with the normalisation plugin gives:

$ ghci -fplugin=GHC.TypeLits.Normalise Test.hs
GHCi, version 8.6.0.20180907: http://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/christiaan/devel/clash-compiler/clash-prelude/.ghc.environment.x86_64-linux-8.6.0.20180907
[1 of 1] Compiling Test             ( Test.hs, interpreted )
Ok, one module loaded.
*Test> 

However, the following session in GHCi doesn't seem to work:

$ ghci -fplugin=GHC.TypeLits.Normalise -XDataKinds -XTypeOperators
GHCi, version 8.6.0.20180907: http://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/christiaan/devel/clash-compiler/clash-prelude/.ghc.environment.x86_64-linux-8.6.0.20180907
Prelude> import Data.Proxy
Prelude Data.Proxy> import GHC.TypeLits
Prelude Data.Proxy GHC.TypeLits> :{
Prelude Data.Proxy GHC.TypeLits| p1 :: Proxy a -> Proxy b -> Proxy (a + b) -> Proxy (b + a)
Prelude Data.Proxy GHC.TypeLits| p1 _ _ = id
Prelude Data.Proxy GHC.TypeLits| :}

<interactive>:5:10: error:
    • Couldn't match type ‘a + b’ with ‘b + a’
      Expected type: Proxy (a + b) -> Proxy (b + a)
        Actual type: Proxy (b + a) -> Proxy (b + a)
      NB: ‘+’ is a non-injective type family
    • In the expression: id
      In an equation for ‘p1’: p1 _ _ = id
    • Relevant bindings include
        p1 :: Proxy a -> Proxy b -> Proxy (a + b) -> Proxy (b + a)
          (bound at <interactive>:5:1)
Prelude Data.Proxy GHC.TypeLits> 

Where such a session did work on GHCi 8.4.3:

$ ghci -fplugin=GHC.TypeLits.Normalise -XDataKinds -XTypeOperators
GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
Loaded package environment from /home/christiaan/devel/clash-compiler/.ghc.environment.x86_64-linux-8.4.3
Prelude> import Data.Proxy
Prelude Data.Proxy> import GHC.TypeLits
Prelude Data.Proxy GHC.TypeLits> :{
Prelude Data.Proxy GHC.TypeLits| p1 :: Proxy a -> Proxy b -> Proxy (a + b) -> Proxy (b + a)
Prelude Data.Proxy GHC.TypeLits| p1 _ _ = id
Prelude Data.Proxy GHC.TypeLits| :}
Prelude Data.Proxy GHC.TypeLits> 
Last edited 2 months ago by darchon (previous) (diff)

comment:3 Changed 2 months ago by darchon

comment:4 Changed 2 months ago by mpickering

I think that is the problem. I don't know off the top of my head where the call needs to be inserted.

comment:5 Changed 6 weeks ago by adamgundry

Cc: adamgundry added
Keywords: TypeCheckerPlugins added

comment:6 Changed 3 days ago by darchon

Differential Rev(s): Phab:D5348
Status: newpatch
Note: See TracTickets for help on using tickets.