TemplateHaskell 似乎没有报告需要导入什么功能

TemplateHaskell seems to not be reporting what function it needs to be imported

此次导入:

 import Data.Singletons.TH
   (
     FalseSym0,
     FromEnum,
     MaxBound,
     MinBound,
     PEq,
     PShow,
     ShowsPrec,
     ShowStringSym0,
     SShow,
     ToEnum,
     TrueSym0,
     sShowsPrec,
     sShowString
   )

失败并出现以下错误:

 error:
         Cannot find type of method Data.Singletons.Prelude.Enum.toEnum
        |
     23 | $(singletons [d|
        |   ^^^^^^^^^^^^^^...

 error: Q monad failure
        |
     23 | $(singletons [d|
        |   ^^^^^^^^^^^^^^...

当导入更改为:

 import Data.Singletons.TH

一切正常。

toEnum 添加到 Data.Singletons.TH 的导入列表将失败:

 error:
         Module ‘Data.Singletons.TH’ does not export ‘toEnum’
        |
     21 |     toEnum
        |     ^^^^^^

据我所知,造成此问题的部分代码如下:

 $(singletons [d|
   data DoorState :: Type where
     Opened :: DoorState
     Closed :: DoorState
     Locked :: DoorState
     deriving (Bounded, Data, Enum, Eq, Show, Typeable)
   |])

 $(singletons [d|
   class Cycle a where
     next :: a -> a
     prev :: a -> a
   |])

 instance forall a. (Bounded a, Enum a, Eq a) => Cycle a where
   next x
     | x == maxBound = minBound
     | otherwise = succ x
   prev x
     | x == minBound = maxBound
     | otherwise = pred x

真正需要添加到导入列表才能使一切正常工作的功能是什么?为什么错误消息中没有报告此功能。

显然,您可以通过完全导入并将“-ddump-minimal-imports”添加到编译选项来获得问题的答案。在您的情况下,您丢失了(对于 lts-13.0):"sError, Sing(SFalse, STrue), PEnum(..), SEnum(..), type (==@#@$), SEq((%==)), ErrorSym0"