相关疑难解决方法(0)

那么:有什么意义呢?

这种So类型的目的是什么?音译到Agda:

data So : Bool ? Set where
  oh : So true
Run Code Online (Sandbox Code Playgroud)

So将布尔命题提升为逻辑命题.Oury和Swierstra的介绍性论文"Pi的力量"给出了一个由表格列索引的关系代数的例子.取两个表的产品要求它们具有不同的列,他们使用这些列So:

Schema = List (String × U)  -- U is the universe of SQL types

-- false iff the schemas share any column names
disjoint : Schema -> Schema -> Bool
disjoint = ...

data RA : Schema ? Set where
  -- ...
  Product : ? {s s'} ? {So (disjoint s s')} ? RA s ? RA s' ? RA …
Run Code Online (Sandbox Code Playgroud)

functional-programming agda dependent-type idris

26
推荐指数
1
解决办法
1621
查看次数

在`a:〜:b`和`(a:== b):〜:True`之间是否有任何联系?

命题促进平等之间是否存在任何联系?

让我说我有

prf :: x :~: y
Run Code Online (Sandbox Code Playgroud)

在某些范围内Symbol; 通过模式匹配Refl,我可以将其转换为

prf' :: (x :== y) :~: True
Run Code Online (Sandbox Code Playgroud)

像这样:

fromProp :: (KnownSymbol x, KnownSymbol y) => x :~: y -> (x :== y) :~: True
fromProp Refl = Refl
Run Code Online (Sandbox Code Playgroud)

但另一个方向呢?如果我试试

toProp :: (KnownSymbol x, KnownSymbol y) => (x :== y) :~: True -> x :~: y
toProp Refl = Refl
Run Code Online (Sandbox Code Playgroud)

然后我得到的就是

• Could not deduce: x ~ y
  from the context: 'True ~ (x …
Run Code Online (Sandbox Code Playgroud)

haskell equality dependent-type type-level-computation singleton-type

8
推荐指数
1
解决办法
219
查看次数

检查一个类型级别列表是否包含另一个

是否可以编写一个类型级函数,True如果一个类型级别列表包含另一个类型级别列表,则返回该函数?

这是我的尝试:

{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

module TypePlayground where

import Data.Type.Bool

type family InList (x :: *) (xs :: [*]) where
    InList x '[] = 'False
    InList x (x ': xs) = 'True
    InList x (a ': xs) = InList x xs
type family ListContainsList (xs :: [*]) (ys :: [*]) where
    ListContainsList xs (y ': ys) = InList y xs && ListContainsList xs ys
    ListContainsList …
Run Code Online (Sandbox Code Playgroud)

haskell

7
推荐指数
2
解决办法
583
查看次数

将Ord实例添加到'singleton'包生成的自然

我使用单一包生成的非常简单的类型级自然.我现在正在尝试向他们添加Ord实例.

{-# LANGUAGE MultiParamTypeClasses, TemplateHaskell, KindSignatures, DataKinds, ScopedTypeVariables, GADTs, TypeFamilies, FlexibleInstances, TypeOperators, UndecidableInstances, InstanceSigs #-}

module Functions where

import Data.Singletons
import Data.Singletons.TH
import Data.Singletons.Prelude
import Data.Promotion.Prelude

singletons [d|
             data Nat = Z | S Nat
               deriving Eq

             instance Ord Nat where
               (<=)    Z     _  = True
               (<=) (S _)    Z  = False
               (<=) (S n) (S m) = n <= m
             |]
Run Code Online (Sandbox Code Playgroud)

我一直在遇到一个错误.最新的一个是:

src/Functions.hs:10:1:
    Couldn't match kind ‘Nat’ with ‘*’
    When matching types
      n0 :: Nat
      t1 :: *
    Expected …
Run Code Online (Sandbox Code Playgroud)

haskell dependent-type template-haskell singleton-type

3
推荐指数
1
解决办法
138
查看次数