我最近发布了一个问题,关于句法2.0有关的定义share.我在GHC 7.6中有这个工作:
{-# LANGUAGE GADTs, TypeOperators, FlexibleContexts #-}
import Data.Syntactic
import Data.Syntactic.Sugar.BindingT
data Let a where
Let :: Let (a :-> (a -> b) :-> Full b)
share :: (Let :<: sup,
sup ~ Domain b, sup ~ Domain a,
Syntactic a, Syntactic b,
Syntactic (a -> b),
SyntacticN (a -> (a -> b) -> b)
fi)
=> a -> (a -> b) -> b
share = sugarSym Let
Run Code Online (Sandbox Code Playgroud)
但是,GHC 7.8希望-XAllowAmbiguousTypes …
无论如何要欺骗haskell(原始haskell?源插件?任何东西?)以获得类型类如何派生的证明树?
我想要什么,使用下面的例子说:
**Diff**
-- --
Id Id
---- ----------
Unit Prod Id Id
---------------------
Sum Unit (Prod Id Id)
Run Code Online (Sandbox Code Playgroud)
**Diff**
-- --
Id Id
---- ----------
Unit Prod Id Id
---------------------
Sum Unit (Prod Id Id)
Run Code Online (Sandbox Code Playgroud) 请考虑以下代码:
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
class Foo a where
type Bar a
class Foo a => Foo2 a where
bar :: Bar a
Run Code Online (Sandbox Code Playgroud)
它在GHC 8.2中给出以下错误消息:
error:
• Couldn't match expected type ‘Bar a’ with actual type ‘Bar a0’
NB: ‘Bar’ is a type function, and may not be injective
The type variable ‘a0’ is ambiguous
• In the ambiguity check for ‘bar’
To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
When checking the class …Run Code Online (Sandbox Code Playgroud)