相关疑难解决方法(0)

什么"Contraint不小于实例头"意味着如何解决它

我想写一些类似的东西:

{-# LANGUAGE FlexibleContexts,FlexibleInstances #-}

import Data.ByteString.Char8 (ByteString,pack)
import Data.Foldable (Foldable)

class (Show a) => Rows a where
    rRepr :: a -> [ByteString]
    rRepr = (:[]) . pack . show

instance (Foldable f,Show (f a)) => Rows (f a) where
    rRepr = const []
Run Code Online (Sandbox Code Playgroud)

意味着f a实例化Rowsif finstanti Foldablef ainstantiate Show.当我运行ghc时,我得到:

Constraint is no smaller than the instance head
  in the constraint: Show (f a)
(Use -XUndecidableInstances to permit this)
In the …
Run Code Online (Sandbox Code Playgroud)

haskell

4
推荐指数
1
解决办法
1237
查看次数

标签 统计

haskell ×1