[ghc-steering-committee] Mind the gap
Chris Dornan
chris at chrisdornan.com
Tue Jul 5 14:00:28 UTC 2022
I should provide some context to this. It is based on a problem that developed in a codebase I was working on — the only one that I am currently developing on GHC 9.2. It worked fine on 8.10 and 9.2 — for production builds — but broke down with bizarre type errors in its 9.2 development configuration. Eventually I wanted to consolidate around GHC 9.2 and spent some time isolating the problem, and realised that I wasn’t tying down the base language configuration in my development environment. I ran out of time before I could isolate the precise extension that was causing the error so I thought I would see if anybody could spot the problem on inspection.
Needless to say it is a huge relief to have identify the underlying problem and am now attaching Haskell2010 to all of my source files in all of my code bases and will be using it in all non-trivial code snippets in blog posts etc. It has become my top language extension with some quite warm and pleasant associations!
In many ways this is probably a positive development — we really should be being more explicit about the flavour of Haskell that we are using.
Chris
> On 2022-07-02, at 05:49, Chris Dornan <chris at chrisdornan.com> wrote:
>
> Quick quiz: the below Haskell2010 ‘Phantoms' module (also in this Gist: https://gist.github.com/cdornan/f75cd8024434d998c87610cbb7fb6ab3) appears (for me on GHC 9.2.2 and 9.2.3) to not be a GHC2021 module, reporting this error under the latter configuration:
>
> Phantoms.hs:22:10: error:
> • Could not deduce (Typeable k)
> arising from the superclasses of an instance declaration
> from the context: (C a, Typeable a)
> bound by the instance declaration
> at Phantoms.hs:22:10-36
> • In the instance declaration for ‘S (D a)’
> |
> 22 | instance (C a,Typeable a) => S (D a) where smethod = undefined
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Phantoms.hs:22:10: error:
> • Could not deduce (Typeable k)
> arising from the superclasses of an instance declaration
> from the context: (C a, Typeable a)
> bound by the instance declaration
> at Phantoms.hs:22:10-36
> • In the instance declaration for ‘S (D a)’
> |
> 22 | instance (C a,Typeable a) => S (D a) where smethod = undefined
>
> The question is which language extension(s) are giving rise to these errors?
>
> The ‘Phantoms' module is this:
>
> {-# LANGUAGE DerivingVia #-}
>
> module Phantoms where
>
> import Data.Typeable
>
>
> class C a where
> cmethod :: Proxy a -> ()
>
> class (Show a, Typeable a) => S a where
> smethod :: a -> Int
>
>
> newtype UsingD a = UsingD { getUsingD :: a }
>
>
> newtype D a = D { getD :: Int }
> deriving (Show) via UsingD (D a)
>
>
> instance (C a,Typeable a) => S (D a) where smethod = undefined
>
> instance (C a,Typeable a) => Show (UsingD a) where showsPrec = undefined
>
>
> instance (C a) => C (D a) where cmethod _ = undefined
>
More information about the ghc-steering-committee
mailing list