【发布时间】:2022-08-20 09:27:46
【问题描述】:
我有 Coord 函数将 n 维大小转换为由给定大小限制的坐标类型:Coord [2,3] = (Fin 2, Fin 3)。
import Data.Fin
import Data.List
Size : Type
Size = List Nat
Coord : Size -> Type
Coord [] = ()
Coord s@(_ :: _) = foldr1 (,) $ map Fin s
我想使用show 和其他功能,如(==) 和Coord s:
foo : Coord s -> String
foo x = show x
Error: While processing right hand side of foo. Can\'t find an implementation for Show (Coord s).
22 | foo : Coord s -> String
23 | foo x = show x
^^^^^^
早些时候我尝试实现Show (Coord s),但看起来这是不可能的。 Here 是关于它的链接问题。
-
将
Coords定义为Vect的Fins 可能会容易得多。 -
@michaelmesser,我不认为这是可能的,因为每个维度都有不同的大小,所以每个坐标组件都有不同的类型。例如
(Fin 2, Fin 3)。 -
然后使用
All而不是Vect