相关疑难解决方法(0)

什么时候-XAllowAmbiguousTypes合适?

我最近发布了一个问题,关于句法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 ghc

212
推荐指数
1
解决办法
6070
查看次数

来自haskell中实例搜索的证明树

无论如何要欺骗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)

haskell

7
推荐指数
1
解决办法
93
查看次数

为什么这种类型变量不明确,尽管它应该在范围内?

请考虑以下代码:

{-# 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)

haskell type-families type-variables

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

标签 统计

haskell ×3

ghc ×1

type-families ×1

type-variables ×1