Haskell:为 Fix 类型派生 Show

Car*_*lin 6 haskell typeclass deriving fixpoint-combinators

我正在尝试使用recursion-schemes. 我希望能够打印它。

import Data.Functor.Foldable

data T1F a = Foo deriving Show
type T1 = Fix T1F
data T2 = Bar T1 deriving Show -- error here
Run Code Online (Sandbox Code Playgroud)

错误信息:

No instance for (Data.Functor.Classes.Show1 T1F)
  arising from the first field of ‘Bar’ (type ‘T1’)
Possible fix:
  use a standalone 'deriving instance' declaration,
    so you can specify the instance context yourself
When deriving the instance for (Show T2)
Run Code Online (Sandbox Code Playgroud)

我如何制作T1派生Show

Car*_*lin 4

使用该包deriving-compat

{-# LANGUAGE TemplateHaskell #-}
import Data.Functor.Foldable
import Text.Show.Deriving

data T1F a = Foo deriving Show
$(deriveShow1 ''T1F)
type T1 = Fix T1F
data T2 = Bar T1 deriving Show
Run Code Online (Sandbox Code Playgroud)