我試圖按照紙張"Scrap your boilerpolate" Revolutions的程序。 不幸的是,我發現程序中擡起的脊椎視圖部分沒有在我的GHC編譯, 有人可以指出我錯在哪裏?擡起的脊椎視圖
{-# LANGUAGE FlexibleContexts, MultiParamTypeClasses,
FlexibleInstances, UndecidableInstances, ScopedTypeVariables,
NoMonomorphismRestriction, DeriveTraversable, DeriveFoldable,
DeriveFunctor, GADTs, KindSignatures, TypeOperators,
TemplateHaskell, BangPatterns
#-}
{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-name-shadowing
-fwarn-monomorphism-restriction -fwarn-hi-shadowing
#-}
module LiftedSpine where
import Test.HUnit
-- Lifted Type View
newtype Id x = InID x
newtype Char' x = InChar' Char
newtype Int' x = InInt' Int
data List' a x = Nil' | Cons' (a x) (List' a x)
data Pair' a b x = InPair' (a x) (b x)
data Tree' a x = Empty' | Node' (Tree' a x) (a x) (Tree' a x)
data Type' :: (* -> *) -> * where
Id :: Type' Id
Char' :: Type' Char'
Int' :: Type' Int'
List' :: Type' a -> Type' (List' a)
Pair' :: Type' a -> Type' b -> Type' (Pair' a b)
Tree' :: Type' a -> Type' (Tree' a)
infixl 1 :->
data Typed' (f :: * -> *) a = (f a) :-> (Type' f)
size :: forall (f :: * -> *) (a :: *) . Typed' f a -> Int
size (Nil' :-> (List' a')) = 0
size (Cons' x xs :-> List' a') =
size (xs :-> List' a') + size (x :-> a')