我正在编码(作为假设)函子恒等律,如下所示:
...
import qualified Prelude ()
...
{-@ class Functor f where
fmap :: forall a b. (a -> b) -> (f a -> f b) @-}
class Functor f where
fmap :: (a -> b) -> (f a -> f b)
-- identity function
{-@ id :: forall a . x : a -> {y : a | x = y} @-}
id :: forall a . a -> a
id x = x
-- functor law: mapping with identity is identity
{-@ assume
fmap_id :: forall f a . Functor f => x : f a ->
{fmap id x = id x} @-}
fmap_id :: Functor f => f a -> ()
fmap_id _ = ()
我看不出这个公式有什么问题,但是我从 LH 那里得到了这个错误:
src/Category/Functor/LH.hs:45:16: error:
• Illegal type specification for `Category.Functor.LH.fmap_id`
Category.Functor.LH.fmap_id :: forall f a .
(Functor<[]> f) =>
x:f a -> {VV : () | Category.Functor.LH.fmap Category.Functor.LH.id x == Category.Functor.LH.id x}
Sort Error in Refinement: {VV : Tuple | Category.Functor.LH.fmap Category.Functor.LH.id x == Category.Functor.LH.id x}
Unbound symbol Category.Functor.LH.fmap --- perhaps you meant: Category.Functor.LH.C:Functor ?
•
|
45 | fmap_id :: forall f a . Functor f => x : f a ->
|
我究竟做错了什么?我的目标是用可扩展性来表述这个无点,但至少这个逐点表述应该首先起作用。
配置:
- GHC 版本:8.10.1
- 阴谋集团版本:3.2.0.0
- Liquid Haskell 版本:0.8.10.2