简体   繁体   English

MTL库需要哪些语言扩展?

[英]What language extensions does the MTL library require?

I'm trying to understand monad transformers by implementing my own tiny library based on the designs of existing ones. 我试图通过基于现有设计实现我自己的小型库来理解monad变换器。

What I'm stuck on is the language extensions. 我坚持的是语言扩展。 In MonadError , the only extension mentioned is UndecidableInstances . MonadError中 ,提到的唯一扩展是UndecidableInstances However, I can't get similar code to compile without also using FunctionalDependencies and FlexibleInstances . 但是,如果不使用FunctionalDependenciesFlexibleInstances ,我无法获得类似的代码。

Example that I believe requires FunDeps: 我认为需要FunDeps的例子:

class (Monad m) => MonadError e m | m -> e where

And a flexible instance: 一个灵活的实例:

instance MonadError e m => MonadError e (MaybeT m) where

How does the MonadError code avoid the extra two extensions? MonadError代码如何避免额外的两个扩展?

You don't have to spell out all the extensions in the source file itself. 您不必拼写源文件本身的所有扩展名。 Common extensions that are used by all/most modules can be listed in the project's cabal file. 所有/大多数模块使用的公共扩展可以列在项目的cabal文件中。 In mtl's case : mtl的情况下

extensions:
    MultiParamTypeClasses
    FunctionalDependencies
    FlexibleInstances

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 parseModule 无法将某些语言扩展识别为已启用 - parseModule does not recognize some language extensions as enabled 什么是免费monads vs mtl辩论? - What is the free monads vs mtl debate? 是否可以“隐藏”语言扩展? - Is it possible to “hide” language extensions? EclipseFP中Haskell的语言扩展 - Language extensions for Haskell in EclipseFP 哪些语言扩展能够编写“A类(B c)=> D c哪里......”? 这种类型声明的含义是什么? - Which language extensions enable to write “class A (B c) => D c where …” ? What is the meaning of this type class declaration? “纯粹”在“纯函数式语言”中意味着什么? - What does “pure” mean in “pure functional language”? 依靠强制语言的一致性意味着什么? - What does it mean to rely on the consistency of a coercion language? 共享在函数式编程语言的实现中引用了什么 - What does sharing refer to in the implementation of a functional programming language 使用函数编程语言处理具有内部状态的外部库的最优雅方法是什么? - What is the most elegant way to deal with an external library with internal state using a function programming language? ($ =)(美元等于)运算符在Haskell GLUT库中做什么? - What does the ($=) (dollar equals) operator do in Haskell GLUT library?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM