小编use*_*233的帖子

类型同义词究竟是如何工作的?

如何进行,以下类型检查

{-# LANGUAGE RankNTypes #-}
module Main where

class Foo a where


type FunFoo = (Foo a) => a -> IO ()

data Bar = Bar {
  funFoo :: FunFoo
}

setFunFoo :: FunFoo -> Bar -> Bar
setFunFoo action bar = bar {funFoo = action}
Run Code Online (Sandbox Code Playgroud)

但是当将setFunFoo的类型签名更改为

setFunFoo :: ((Foo a) => a -> IO ()) -> Bar -> Bar
Run Code Online (Sandbox Code Playgroud)

它不是?有没有一种方法来表达上面的代码没有类型同义词FunFoo?

haskell types type-systems higher-rank-types

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

标签 统计

haskell ×1

higher-rank-types ×1

type-systems ×1

types ×1