Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

internal error: extractDecl when selectively reexporting data instance #979

Closed
watashi opened this issue Dec 13, 2018 · 13 comments
Closed

Comments

@watashi
Copy link
Contributor

watashi commented Dec 13, 2018

Env

  • ghc and haddock built from ghc master
$ uname -a
Linux localhost 4.18.8-arch1-1-ARCH #1 SMP PREEMPT Sat Sep 15 20:34:48 UTC 2018 x86_64 GNU/Linux
$ cabal --version
cabal-install version 2.5.0.0
compiled using version 2.5.0.0 of the Cabal library 

Repro

Here is the minimal repro I constructed, with two packages where pkg2 depends on pkg1:

$ cat pkg1/A.hs
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilies #-}
module A
  ( C(..)  -- [1]
  , T(TI)
  , error
  ) where

class C a where
  data T a

instance C Int where
  data T Int = TI { ti :: Int }

$ cat pkg2/B.hs
module B
  ( module A
  ) where

import A hiding (error) -- [2]

$ cabal sandbox init
$ cabal add-source pkg1 pkg2
$ cabal install pkg1 pkg2 --with-ghc ~/ghc/inplace/bin/ghc-stage2 --with-haddock ~/ghc/inplace/bin/haddock --haddock-html --enable-documentation --reinstall
...
haddock: internal error: internal: extractDecl
CallStack (from HasCallStack):
  error, called at src/Haddock/Interface/Create.hs:1116:12 in haddock-api-2.22.0-inplace:Haddock.Interface.Create
...

Issue

I looked into this a little bit and this is what the callstack looks like:

mkExportItems _...
  Just [(module A, [C{T}, T{TI}])] -- exportList: without @C(..)@ at [1], this will be [T{T}, T{TI}]
  [T{TI}, C{T}] -- allExports; without @C(..)@ at [1], this will be [T{T, TI}] and haddock works
  _ _
-- we go to the last case of 'lookupExport' (haddock works without @hiding (error)@ at [2]
availExportItem _... T{TI}
-- the decl of 'T' is from another package: 'hiDecl' returns @data family T a :: Type@ (haddock works otherwise)
availExportDecl T{TI} (data family T a :: Type) (_, [(TI, _)])
-- @availExportsDecl avail@ is 'False', so we handle the sub one 'TI'
extractDecl [] TI (data family T a :: Type)
-- name doesn't exist in the decl returned by 

availExportsDecl depends on the invariants stated in Avail that if the type or class is itself to be in scope, it must be first in this list. But this invariant doesn't quite hold for data instance above?

Not sure what's the best way to fix this, we can at least suppress this error by intentionally ignoring this case.

watashi added a commit to watashi/haddock that referenced this issue Dec 13, 2018
harpocrates pushed a commit that referenced this issue Dec 14, 2018
@harpocrates
Copy link
Collaborator

I'm having a tough time replicating this. What GHC commit were you using?

@watashi
Copy link
Contributor Author

watashi commented Dec 19, 2018

@harpocrates I was able to repro this on a very recent commit ghc/ghc@548becd

Here is a complete repro:

$ cat | base64 -d > bug979.tar.gz
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
BQUFBQUFBQUFBQWFd4b/AzCdCasAUAAA
$ tar xf bug979.tar.gz
$ cabal sandbox init
$ cabal sandbox add-source pkg1 pkg2
$ cabal install pkg1 pkg2 --with-ghc ~/ghc/inplace/bin/ghc-stage2 --with-haddock ~/ghc/inplace/bin/haddock --haddock-html --enable-documentation
...
haddock: internal error: internal: extractDecl
CallStack (from HasCallStack):
  error, called at utils/haddock/haddock-api/src/Haddock/Interface/Create.hs:1116:12 in main:Haddock.Interface.Create
...

@harpocrates
Copy link
Collaborator

OK, I can replicate now. This looks like a GHC bug; check out the avails reported by tcg_exports:

  • for A, you get [error, C{C, T;}, T{T, TI;}]
  • for B, you get [T{TI;}, C{C, T;}]

I'll see if I can diagnose the issue in GHC. If not, you're right we should at least patch Haddock (and leave this issue open as a reminder).

@harpocrates
Copy link
Collaborator

I've opened https://ghc.haskell.org/trac/ghc/ticket/16077 regarding the Avail invariant being violated.

@brandon-leapyear
Copy link

brandon-leapyear commented Dec 29, 2018

This is an old work account. Please reference @brandonchinn178 for all future communication


Hi! Getting a similar error over in esqueleto

The problem is possibly the re-export of BackendKey, a data family, in https://github.com/bitemyapp/esqueleto/blob/master/src/Database/Esqueleto/Internal/PersistentImport.hs

Update:
In the process of debugging, I printed out renamedSource tm for the problematic module Database.Esqueleto.Internal.PersistentImport, and I get the following values:

-- group_
""

-- imports_
[import (implicit) Prelude,
       import Database.Persist.Sql
           hiding ( BackendSpecificFilter,
                    BackendSpecificFilter,
                    Filter(..),
                    PersistQuery,
                    SelectOpt(..),
                    Update(..),
                    delete,
                    deleteWhereCount,
                    updateWhereCount,
                    selectList,
                    selectKeysList,
                    deleteCascadeWhere,
                    (=.),
                    (+=.),
                    (-=.),
                    (*=.),
                    (/=.),
                    (==.),
                    (!=.),
                    (<.),
                    (>.),
                    (<=.),
                    (>=.),
                    (<-.),
                    (/<-.),
                    (||.),
                    listToJSON,
                    mapToJSON,
                    getPersistMap,
                    limitOffsetOrder,
                    selectSource,
                    update,
                    count )]

-- mayExports
Just [(module Database.Persist.Sql,
             [PersistEntity{Key;}, PersistEntity{Unique;}, Single{Single;},
              PersistConfig{PersistConfig;},
              PersistConfig{PersistConfigBackend;},
              PersistConfig{PersistConfigPool;}, PersistUpdate{PersistUpdate;},
              BackendSpecificUpdate{BackendSpecificUpdate;},
              OnlyUniqueException{OnlyUniqueException;},
              UpdateException{UpdateException;}, PersistFilter{PersistFilter;},
              SqlType{SqlType;}, PersistValue{PersistValue;},
              PersistException{PersistException;}, ForeignDef{ForeignDef;},
              ForeignFieldDef{ForeignFieldDef;}, CompositeDef{CompositeDef;},
              UniqueDef{UniqueDef;}, EmbedFieldDef{EmbedFieldDef;},
              EmbedEntityDef{EmbedEntityDef;}, ReferenceDef{ReferenceDef;},
              FieldDef{FieldDef;}, FieldType{FieldType;}, Attr{Attr;},
              DBName{DBName;}, HaskellName{HaskellName;}, ExtraLine{ExtraLine;},
              EntityDef{EntityDef;}, WhyNullable{WhyNullable;},
              IsNullable{IsNullable;}, Checkmark{Checkmark;},
              SomePersistField{SomePersistField;}, PersistField{PersistField;},
              Entity{Entity;}, PersistEntity{PersistEntity;},
              PersistEntity{PersistEntityBackend;}, PersistEntity{EntityField;},
              PersistStoreWrite{PersistStoreWrite;},
              PersistStoreRead{PersistStoreRead;}, PersistCore{PersistCore;},
              PersistCore{BackendKey;}, ToBackendKey{ToBackendKey;},
              PersistRecordBackend{PersistRecordBackend;},
              BackendCompatible{BackendCompatible;},
              IsPersistBackend{IsPersistBackend;},
              HasPersistBackend{HasPersistBackend;},
              HasPersistBackend{BaseBackend;},
              PersistUniqueWrite{PersistUniqueWrite;},
              PersistUniqueRead{PersistUniqueRead;},
              PersistQueryWrite{PersistQueryWrite;},
              PersistQueryRead{PersistQueryRead;}, DeleteCascade{DeleteCascade;},
              PersistStore{PersistStore;}, PersistUnique{PersistUnique;},
              IsSqlBackend{IsSqlBackend;}, SqlWriteT{SqlWriteT;},
              SqlReadT{SqlReadT;}, SqlBackendCanWrite{SqlBackendCanWrite;},
              SqlBackendCanRead{SqlBackendCanRead;},
              SqlWriteBackend{SqlWriteBackend;}, SqlReadBackend{SqlReadBackend;},
              SqlBackend{SqlBackend;}, Statement{Statement;},
              InsertSqlResult{InsertSqlResult;}, LogFunc{LogFunc;},
              ConnectionPool{ConnectionPool;}, Migration{Migration;},
              CautiousMigration{CautiousMigration;}, Sql{Sql;},
              SqlPersistM{SqlPersistM;}, SqlPersist{SqlPersist;},
              SqlPersistT{SqlPersistT;},
              PersistentSqlException{PersistentSqlException;}, Column{Column;},
              Connection{Connection;}, PersistFieldSql{PersistFieldSql;},
              RawSql{RawSql;}, PersistFilter{Eq;}, Single{Single;},
              PersistUpdate{Assign;}, PersistUpdate{Add;},
              PersistUpdate{Subtract;}, PersistUpdate{Multiply;},
              PersistUpdate{Divide;}, PersistUpdate{BackendSpecificUpdate;},
              OnlyUniqueException{OnlyUniqueException;},
              UpdateException{KeyNotFound;}, UpdateException{UpsertError;},
              PersistFilter{Ne;}, PersistFilter{Gt;}, PersistFilter{Lt;},
              PersistFilter{Ge;}, PersistFilter{Le;}, PersistFilter{In;},
              PersistFilter{NotIn;}, SqlType{SqlString;}, SqlType{SqlInt32;},
              SqlType{SqlInt64;}, SqlType{SqlReal;}, SqlType{SqlNumeric;},
              SqlType{SqlBool;}, SqlType{SqlDay;}, SqlType{SqlTime;},
              SqlType{SqlDayTime;}, SqlType{SqlBlob;}, SqlType{SqlOther;},
              PersistValue{PersistText;}, PersistValue{PersistByteString;},
              PersistValue{PersistInt64;}, PersistValue{PersistDouble;},
              PersistValue{PersistRational;}, PersistValue{PersistBool;},
              PersistValue{PersistDay;}, PersistValue{PersistTimeOfDay;},
              PersistValue{PersistUTCTime;}, PersistValue{PersistNull;},
              PersistValue{PersistList;}, PersistValue{PersistMap;},
              PersistValue{PersistObjectId;}, PersistValue{PersistDbSpecific;},
              PersistException{PersistError;},
              PersistException{PersistMarshalError;},
              PersistException{PersistInvalidField;},
              PersistException{PersistForeignConstraintUnmet;},
              PersistException{PersistMongoDBError;},
              PersistException{PersistMongoDBUnsupported;},
              ForeignDef{ForeignDef;}, CompositeDef{CompositeDef;},
              UniqueDef{UniqueDef;}, EmbedFieldDef{EmbedFieldDef;},
              EmbedEntityDef{EmbedEntityDef;}, ReferenceDef{NoReference;},
              ReferenceDef{ForeignRef;}, ReferenceDef{EmbedRef;},
              ReferenceDef{CompositeRef;}, ReferenceDef{SelfReference;},
              FieldDef{FieldDef;}, FieldType{FTTypeCon;}, FieldType{FTApp;},
              FieldType{FTList;}, DBName{DBName;}, HaskellName{HaskellName;},
              EntityDef{EntityDef;}, WhyNullable{ByMaybeAttr;},
              WhyNullable{ByNullableAttr;}, IsNullable{Nullable;},
              IsNullable{NotNullable;}, Checkmark{Active;}, Checkmark{Inactive;},
              SomePersistField{SomePersistField;}, Entity{Entity;},
              SqlBackend{SqlBackend;}, Statement{Statement;},
              InsertSqlResult{ISRSingle;}, InsertSqlResult{ISRInsertGet;},
              InsertSqlResult{ISRManyKeys;},
              PersistentSqlException{StatementAlreadyFinalized;},
              PersistentSqlException{Couldn'tGetSQLConnection;}, Column{Column;},
              BackendKey{SqlWriteBackendKey;}, BackendKey{SqlReadBackendKey;},
              BackendKey{SqlBackendKey;}, PersistStoreRead{get;},
              PersistUniqueWrite{deleteBy;}, PersistStoreWrite{insert;},
              insertBy, migrate, PersistStoreRead{getMany;}, rawSql,
              PersistConfig{loadConfig;}, PersistConfig{applyEnv;},
              PersistConfig{createPoolConfig;}, PersistConfig{runPool;},
              ForeignDef{; foreignRefTableHaskell},
              ForeignDef{; foreignRefTableDBName},
              ForeignDef{; foreignConstraintNameHaskell},
              ForeignDef{; foreignConstraintNameDBName},
              ForeignDef{; foreignFields}, ForeignDef{; foreignAttrs},
              ForeignDef{; foreignNullable}, CompositeDef{; compositeFields},
              CompositeDef{; compositeAttrs}, UniqueDef{; uniqueHaskell},
              UniqueDef{; uniqueDBName}, UniqueDef{; uniqueFields},
              UniqueDef{; uniqueAttrs}, EmbedFieldDef{; emFieldDB},
              EmbedFieldDef{; emFieldEmbed}, EmbedFieldDef{; emFieldCycle},
              EmbedEntityDef{; embeddedHaskell},
              EmbedEntityDef{; embeddedFields}, FieldDef{; fieldHaskell},
              FieldDef{; fieldDB}, FieldDef{; fieldType},
              FieldDef{; fieldSqlType}, FieldDef{; fieldAttrs},
              FieldDef{; fieldStrict}, FieldDef{; fieldReference},
              DBName{; unDBName}, HaskellName{; unHaskellName},
              EntityDef{; entityHaskell}, EntityDef{; entityDB},
              EntityDef{; entityId}, EntityDef{; entityAttrs},
              EntityDef{; entityFields}, EntityDef{; entityUniques},
              EntityDef{; entityForeigns}, EntityDef{; entityDerives},
              EntityDef{; entityExtra}, EntityDef{; entitySum}, entityPrimary,
              entityKeyFields, keyAndEntityFields, toEmbedEntityDef,
              fromPersistValueText, PersistField{toPersistValue;},
              PersistField{fromPersistValue;}, Entity{; entityKey},
              Entity{; entityVal}, PersistEntity{keyToValues;},
              PersistEntity{keyFromValues;}, PersistEntity{persistIdField;},
              PersistEntity{entityDef;}, PersistEntity{persistFieldDef;},
              PersistEntity{toPersistFields;}, PersistEntity{fromPersistValues;},
              PersistEntity{persistUniqueKeys;},
              PersistEntity{persistUniqueToFieldNames;},
              PersistEntity{persistUniqueToValues;}, PersistEntity{fieldLens;},
              entityValues, keyValueEntityToJSON, keyValueEntityFromJSON,
              entityIdToJSON, entityIdFromJSON, toPersistValueJSON,
              fromPersistValueJSON, PersistStoreWrite{insert_;},
              PersistStoreWrite{insertMany;}, PersistStoreWrite{insertMany_;},
              PersistStoreWrite{insertEntityMany;},
              PersistStoreWrite{insertKey;}, PersistStoreWrite{repsert;},
              PersistStoreWrite{repsertMany;}, PersistStoreWrite{replace;},
              PersistStoreWrite{updateGet;}, ToBackendKey{toBackendKey;},
              ToBackendKey{fromBackendKey;}, BackendCompatible{projectBackend;},
              HasPersistBackend{persistBackend;}, liftPersist, getJust,
              getJustEntity, belongsTo, belongsToJust, insertEntity, getEntity,
              insertRecord, PersistUniqueWrite{insertUnique;},
              PersistUniqueWrite{upsert;}, PersistUniqueWrite{upsertBy;},
              PersistUniqueWrite{putMany;}, PersistUniqueRead{getBy;},
              insertUniqueEntity, onlyUnique, getByValue, replaceUnique,
              checkUnique, PersistQueryWrite{updateWhere;},
              PersistQueryWrite{deleteWhere;},
              PersistQueryRead{selectSourceRes;}, PersistQueryRead{selectFirst;},
              PersistQueryRead{selectKeysRes;}, selectKeys,
              DeleteCascade{deleteCascade;},
              SqlWriteBackend{; unSqlWriteBackend},
              SqlReadBackend{; unSqlReadBackend}, SqlBackend{; connPrepare},
              SqlBackend{; connInsertSql}, SqlBackend{; connInsertManySql},
              SqlBackend{; connUpsertSql}, SqlBackend{; connPutManySql},
              SqlBackend{; connStmtMap}, SqlBackend{; connClose},
              SqlBackend{; connMigrateSql}, SqlBackend{; connBegin},
              SqlBackend{; connCommit}, SqlBackend{; connRollback},
              SqlBackend{; connEscapeName}, SqlBackend{; connNoLimit},
              SqlBackend{; connRDBMS}, SqlBackend{; connLimitOffset},
              SqlBackend{; connLogFunc}, SqlBackend{; connMaxParams},
              Statement{; stmtFinalize}, Statement{; stmtReset},
              Statement{; stmtExecute}, Statement{; stmtQuery}, writeToUnknown,
              readToWrite, readToUnknown, Single{; unSingle}, Column{; cName},
              Column{; cNull}, Column{; cSqlType}, Column{; cDefault},
              Column{; cDefaultConstraintName}, Column{; cMaxLen},
              Column{; cReference}, defaultAttribute, mkColumns, toJsonText,
              PersistFieldSql{sqlType;}, RawSql{rawSqlCols;},
              RawSql{rawSqlColCountReason;}, RawSql{rawSqlProcessRow;}, rawQuery,
              rawQueryRes, rawExecute, rawExecuteCount, getStmtConn, runSqlPool,
              runSqlConn, runSqlPersistM, runSqlPersistMPool,
              liftSqlPersistMPool, withSqlPool, createSqlPool, askLogFunc,
              withSqlConn, close', BackendKey{; unSqlWriteBackendKey},
              BackendKey{; unSqlReadBackendKey}, BackendKey{; unSqlBackendKey},
              withRawQuery, toSqlKey, fromSqlKey, getTableName, tableDBName,
              getFieldName, fieldDBName, sqlQQ, executeQQ,
              decorateSQLWithLimitOffset, parseMigration, parseMigration',
              printMigration, showMigration, getMigration, runMigration,
              runMigrationSilent, runMigrationUnsafe, transactionSave,
              transactionUndo])]

-- mayDocHeader
Just  Re-export "Database.Persist.Sql" without any clashes with @esqueleto@.

It looks like maybe group_ is the issue, since declMap is built from group_, so an empty group_ would mean an empty declMap, which would fail the FamDecl case. Unsure why this would be broken in 8.4 and not 8.2, however.

Hope this helps!

@brandon-leapyear
Copy link

brandon-leapyear commented Dec 29, 2018

This is an old work account. Please reference @brandonchinn178 for all future communication


So it seems like on ghc-8.2.2, the export list is kept at just the module

-- group_
""

-- imports
[import (implicit) Prelude,
       import Database.Persist.Sql
           hiding ( BackendSpecificFilter,
                    BackendSpecificFilter,
                    Filter(..),
                    PersistQuery,
                    SelectOpt(..),
                    Update(..),
                    delete,
                    deleteWhereCount,
                    updateWhereCount,
                    selectList,
                    selectKeysList,
                    deleteCascadeWhere,
                    (=.),
                    (+=.),
                    (-=.),
                    (*=.),
                    (/=.),
                    (==.),
                    (!=.),
                    (<.),
                    (>.),
                    (<=.),
                    (>=.),
                    (<-.),
                    (/<-.),
                    (||.),
                    listToJSON,
                    mapToJSON,
                    getPersistMap,
                    limitOffsetOrder,
                    selectSource,
                    update,
                    count )],

-- mayExports
Just [module Database.Persist.Sql]

-- mayDocHeader
Just  Re-export "Database.Persist.Sql" without any clashes with\n @esqueleto@.

So it wasn't hitting the DataFam case in extractDecl

juhp added a commit to commercialhaskell/stackage that referenced this issue Jan 3, 2019
Haddock coverage:
haddock: internal error: internal: extractDecl
CallStack (from HasCallStack):
  error, called at utils/haddock/haddock-api/src/Haddock/Interface/Create.hs:1116:12 in main:Haddock.Interface.Create
@Vlix
Copy link

Vlix commented Jan 31, 2019

Any news on this bug? Is there a way to work around it until it's fixed?

@harpocrates
Copy link
Collaborator

This GHC patch should fix the issue: https://gitlab.haskell.org/ghc/ghc/merge_requests/276. At the very least, it fixes the test case from #979 (comment). No Haddock change will be required: this is just GHC not obeying one of its own invariants.

In the meantime, it should be possible to work around this issue by replacing the problematic module re-exports with explicit export lists. I know this isn't a great state of affairs, but I'm not sure what more can be done for now. 😕

It would eventually be nice for Haddock to be more flexible around its error handling (for example: printing errors and exiting with an error code, but still producing a best effort at docs), but there are more pressing problems at the moment...

bgamari pushed a commit to ghc/ghc that referenced this issue Feb 19, 2019
The AvailTC was not be upheld for explicit export module
export lists when the module contains associated data families.

    module A (module A) where
    class    C a  where { data T a }
    instance C () where { data T () = D }

Used to (incorrectly) report avails as `[C{C, T;}, T{D;}]`. Note that
although `T` is exported, the avail where it is the parent does _not_
list it as its first element. This avail is now correctly listed as
`[C{C, T;}, T{T, D;}]`.

This was induces a [crash in Haddock][0].

See #16077.

[0]: haskell/haddock#979
bgamari pushed a commit to ghc/ghc that referenced this issue Feb 19, 2019
The AvailTC was not be upheld for explicit export module
export lists when the module contains associated data families.

    module A (module A) where
    class    C a  where { data T a }
    instance C () where { data T () = D }

Used to (incorrectly) report avails as `[C{C, T;}, T{D;}]`. Note that
although `T` is exported, the avail where it is the parent does _not_
list it as its first element. This avail is now correctly listed as
`[C{C, T;}, T{T, D;}]`.

This was induces a [crash in Haddock][0].

See #16077.

[0]: haskell/haddock#979
bgamari pushed a commit to ghc/ghc that referenced this issue Feb 20, 2019
The AvailTC was not be upheld for explicit export module
export lists when the module contains associated data families.

    module A (module A) where
    class    C a  where { data T a }
    instance C () where { data T () = D }

Used to (incorrectly) report avails as `[C{C, T;}, T{D;}]`. Note that
although `T` is exported, the avail where it is the parent does _not_
list it as its first element. This avail is now correctly listed as
`[C{C, T;}, T{T, D;}]`.

This was induces a [crash in Haddock][0].

See #16077.

[0]: haskell/haddock#979

(cherry picked from commit a0cd486)
@harpocrates
Copy link
Collaborator

The GHC patch has been merged and cherry-picked to the 8.6 and 8.8 branches. This should mean that this will be fixed in haddock shipping with ghc-8.6.4

@MaxGabriel
Copy link
Contributor

Are other people no longer seeing this when compiling with GHC 8.6.4? I'm still getting the error for e.g. classy-prelude-yesod-1.5.0, and that package is marked as broken because of this bug on the Nix 19.03 release for this bug. https://github.com/NixOS/nixpkgs-channels/blob/3a4ffdd38b56801ce616aa08791121d36769e884/pkgs/development/haskell-modules/configuration-hackage2nix.yaml#L3482

@normenmueller
Copy link

Updated to LTS 13.15 for GHC 8.6.4 but still get this error:

$ stack hoogle
No Hoogle database yet. Automatically building haddocks and hoogle database (use --no-setup to disable) ...
Yapper-0.0.0: unregistering
classy-prelude-yesod-1.5.0: configure
classy-prelude-yesod-1.5.0: build
classy-prelude-yesod-1.5.0: haddock
Progress 1/2

--  While building package classy-prelude-yesod-1.5.0 using:
      /Users/nrm/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 haddock --html --hoogle --html-location=../$pkg-$version/ --haddock-option=--hyperlinked-source --haddock-option=--quickjump
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/nrm/Sources/mdpm/projects/Yapper/.stack-work/logs/classy-prelude-yesod-1.5.0.log

    Configuring classy-prelude-yesod-1.5.0...
    Preprocessing library for classy-prelude-yesod-1.5.0..
    Building library for classy-prelude-yesod-1.5.0..
    [1 of 2] Compiling ClassyPrelude.Yesod ( src/ClassyPrelude/Yesod.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/ClassyPrelude/Yesod.o )
    [2 of 2] Compiling Paths_classy_prelude_yesod ( .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/autogen/Paths_classy_prelude_yesod.hs, .stack-work/dist/x86_64-osx/Cabal-2.4.0.1/build/Paths_classy_prelude_yesod.o )
    Preprocessing library for classy-prelude-yesod-1.5.0..
    Running Haddock on library for classy-prelude-yesod-1.5.0..
    Haddock coverage:
    haddock: internal error: internal: extractDecl
    CallStack (from HasCallStack):
      error, called at utils/haddock/haddock-api/src/Haddock/Interface/Create.hs:1116:12 in main:Haddock.Interface.Create

@5outh
Copy link

5outh commented Apr 3, 2019

I am still seeing this error with LTS 13.15 as well.

@skress
Copy link

skress commented Apr 22, 2019

The reason for haddock's error is a bug in GHC which was fixed (https://gitlab.haskell.org/ghc/ghc/merge_requests/276/commits) but not merged into the 8.6 branch.

So it seems like you need to wait for GHC 8.8 ... or you could checkout GHC's 8.6 branch cherry-pick 2a431640d1 and then compile your fixed GHC ... but that will take a lot of time ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants