Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document GHC 91999 and GHC 86639 #507

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE DeriveFunctor #-}
module AddAFunctor where

data MyFunctor a = MyFunctor a a
deriving Functor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module AddAFunctor where

data MyFunctor a = MyFunctor a a
deriving Functor
10 changes: 10 additions & 0 deletions message-index/messages/GHC-86639/example1/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Require the DerivingFunctor language extension for Functor instances
---

When deriving a `Functor` instance for a datatype in Haskell2010, the
`DerivingFunctor` language extension must be turned on. This can be done with a
pragma at the top of the file, or in build settings.

The `DerivingFunctor` extension is turned on automatically from Haskell2021
onwards.
20 changes: 20 additions & 0 deletions message-index/messages/GHC-86639/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Cannot derive an instance without a corresponding language extension
summary: A language extension must be turned on for a typeclass to be derived.
severity: error
introduced: 9.6.1
---

Some typeclasses can be derived automatically in the `deriving` declaration, but
require a certain language extension to be turned on.

For example, to derive `Functor` on a datatype, the `DeriveFunctor` language
extension must be turned on.

There are many available language extensions for deriving instances, the
appropriate extension depends on the typeclass -- for example, deriving `Functor`
requires the `DeriveFunctor` language extension, deriving `Generic` requires
`DeriveGeneric`, and deriving `Lift` requires `DeriveLift`, among others.

There is more info on deriving instances for extra typeclasses in the [GHC user
manual](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/deriving_extra.html).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module BootModuleDataTypeNotInOrdinaryModule where

data BootModuleOnlyDataType = BootModuleOnlyDataType String
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module BootModuleDataTypeNotInOrdinaryModule where

data BootModuleOnlyDataType = BootModuleOnlyDataType String
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ImportBootModule where

import {-# SOURCE #-} BootModuleDataTypeNotInOrdinaryModule
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module BootModuleDataTypeNotInOrdinaryModule where

-- Defined only in the .hs-boot version of this module
-- data BootModuleOnlyDataType = BootModuleOnlyDataType String
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module BootModuleDataTypeNotInOrdinaryModule where

data BootModuleOnlyDataType = BootModuleOnlyDataType String
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ImportBootModule where

import {-# SOURCE #-} BootModuleDataTypeNotInOrdinaryModule
26 changes: 26 additions & 0 deletions message-index/messages/GHC-91999/example1/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Boot module has a datatype which isn't in its corresponding ordinary module
---

In this example, we define a datatype `BootModuleOnlyDataType` in
`BootModuleDataTypeNotInOrdinaryModule.hs-boot`.

Compile the example files like so:

```sh
ghc -c BootModuleDataTypeNotInOrdinaryModule.hs-boot
ghc -c ImportBootModule.hs
ghc -c BootModuleDataTypeNotInOrdinaryModule.hs
```

In the before case, where we defined the datatype `BootModuleOnlyDataType` only
in `BootModuleDataTypeNotInOrdinaryModule.hs-boot`, we compile the modules like
so and receive the following error:

```
<no location info>: error:
‘BootModuleDataTypeNotInOrdinaryModule.BootModuleOnlyDataType’ is exported by the hs-boot file, but not exported by the module
```

In the after case, we add the datatype to
`BootModuleDataTypeNotInOrdinaryModule.hs`, and the error disappears.
11 changes: 11 additions & 0 deletions message-index/messages/GHC-91999/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Missing Boot Export
summary: An hs-boot file exports a datatype that isn't found in its corresponding .hs file
severity: error
introduced: 9.8.1
---

Any datatype that is exported from an .hs-boot file must be exported from the
corresponding .hs file.

More information on .hs-boot modules is available in [the GHC user manual](https://downloads.haskell.org/ghc/latest/docs/users_guide/separate_compilation.html#how-to-compile-mutually-recursive-modules).
Loading