Haskell错误的含义是什么:类型'B'找不到必需的祖先'A'

时间:2017-12-23 12:18:07

标签: haskell

Haskell错误的含义是什么:

  

类型'B'找不到必需的祖先'A'。

1 个答案:

答案 0 :(得分:7)

这不是Haskell错误;这是来自Data.GI.Base.Overloading模块的自定义消息:

https://github.com/haskell-gi/haskell-gi/blob/0c66d9ebab48285c22a96fb0221d8d77d78beaba/base/Data/GI/Base/Overloading.hs#L87-L106

#if MIN_VERSION_base(4,9,0)
-- | Type error to be generated when an ancestor check fails.
type family UnknownAncestorError (a :: *) (t :: *) where
    UnknownAncestorError a t =
        TypeError ('Text "Required ancestor ‘" ':<>: 'ShowType a
                   ':<>: 'Text "’ not found for type ‘"
                   ':<>: 'ShowType t ':<>: 'Text "’.")
#endif

-- | Check whether a type appears in a list. We specialize the
-- names/types a bit so the error messages are more informative.
type family CheckForAncestorType t (a :: *) (as :: [*]) :: AncestorCheck * * where
    CheckForAncestorType t a '[] =
#if !MIN_VERSION_base(4,9,0)
        'DoesNotHaveRequiredAncestor "Error: Required ancestor" a "not found for type" t
#else
        UnknownAncestorError a t
#endif
    CheckForAncestorType t a (a ': as) = 'HasAncestor a t
    CheckForAncestorType t a (b ': as) = CheckForAncestorType t a as