相关疑难解决方法(0)

无法在单身人士图书馆的两个存在中推断出KnownNat

我正在试验单身人士图书馆,我发现了一个我不理解的案例.

{-# LANGUAGE GADTs, StandaloneDeriving, RankNTypes, ScopedTypeVariables,
FlexibleInstances, KindSignatures, DataKinds, StandaloneDeriving  #-}

import Data.Singletons.Prelude
import Data.Singletons.TypeLits

data Foo (a :: Nat) where
 Foo :: Foo a
  deriving Show

data Thing where
  Thing :: KnownNat a => Foo a -> Thing

deriving instance Show Thing

afoo1 :: Foo 1
afoo1 = Foo 

afoo2 :: Foo 2
afoo2 = Foo 

athing :: Thing
athing = Thing afoo1

foolen :: forall n. KnownNat n => Foo n -> Integer
foolen foo =
  case …
Run Code Online (Sandbox Code Playgroud)

haskell existential-type dependent-type

9
推荐指数
1
解决办法
203
查看次数

标签 统计

dependent-type ×1

existential-type ×1

haskell ×1