我收到此代码的错误,我不明白冲突在哪里。
{-# LANGUAGE TypeFamilies, FlexibleContexts, FlexibleInstances,
UndecidableInstances #-}
import Codec.Gray (integralToGray, grayToIntegral)
import Data.List (foldl', unfoldr)
import Data.Word (Word8)
import Prelude hiding (read)
class Gene g where
type Sequence g
write :: Sequence g -> g -> Sequence g
read :: Sequence g -> Maybe (g, Sequence g)
instance (Gene a, Sequence a ~ [k], Integral k, Gene k, Sequence k ~ [k]) => Gene [a] where
type Sequence [a] = Sequence a -- LINE 15
write xs gs = Nothing -- stub
read xs = Nothing -- stub
class (Enum g, Bounded g) => Word8Enum g where
writeEnum :: [Word8] -> g -> [Word8]
writeEnum xs g = Nothing -- stub
readEnum :: g -> [Word8] -> Maybe (g, [Word8])
readEnum _ [] = Nothing
readEnum model (x:xs) = Nothing -- stub
instance (Word8Enum g) => Gene g where
type Sequence g = [Word8] -- LINE 29
write = writeEnum
read = readEnum undefined
当我将代码加载到 GHC 中时,出现以下错误:
λ> :l amy4
[1 of 1] Compiling Main ( amy4.hs, interpreted )
amy4.hs:15:8:
Conflicting family instance declarations:
type Sequence [a] -- Defined at amy4.hs:15:8
type Sequence g -- Defined at amy4.hs:29:8
Failed, modules loaded: none.