加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Scala中的泛型编程和烂香蕉涉及功能依赖

发布时间:2020-12-16 18:33:35 所属栏目:安全 来源:网络整理
导读:因此,仅为了初学者(不一定要排除我自己)的情境化,仿函数是A级上下文/映射抽象.在 Scalanese: trait FunctorStr[F[_]] { def map[A,B](f: A = B): F[A] = F[B] } 很多东西都是运算符等等,现在如果你对通用编程和DSL制作感兴趣,那么设计模式的运算符会出现很
因此,仅为了初学者(不一定要排除我自己)的情境化,仿函数是A级上下文/映射抽象.在 Scalanese:

trait FunctorStr[F[_]] {
    def map[A,B](f: A => B): F[A] => F[B]
 }

很多东西都是运算符等等,现在如果你对通用编程和DSL制作感兴趣,那么设计模式的运算符会出现很多.因此,为了与扩展直觉的主题保持一致,让我们深入了解它.在comonad.com’s Rotten Bananas中途我们被介绍到Cata班

在Haskellese中给出:

class Cata f t | t -> f where
  cata:: (f a -> a) -> t -> a

现在这个类接近我们读者的乐趣的开始,但对我来说scala实现者……
Cata是我们麻烦的开始

这种功能依赖性t – > f是否意味着“f由t唯一确定”?
如果你问Miles Sabin in 2011
fundep模式完全可以在scala中实现,并且简单地涉及通过隐式参数部分启动隐式搜索并见证类型以解决搜索但我不能说我得到它以便立即转换t – > f到斯卡拉

我在scala中看到它就像是

abstract class Cata[F[_],T](implicit e: ???) {
   def cata[A]: (F[A] => A) => T => A
}

trait CataFunctor[F[_]] extends FunctorStr[({type l[x] = Cata[F,x]})#l] {
   def map[A,B](f: A => B): Cata[F,A] => Cata[F,B]
}

引用文章:

given cata and fmap one can go through and build up a whole host of
other recursion schemes,paramorphisms,zygomorphisms,histomorphisms,
generalized catamorphisms,…; the menagerie is quite forbidding and
these can be used to tear apart covariant functors with reckless
abandon. With the power of a paramorphism you rederive the notion of
general recursion,and so you can basically write any recursive
function you want. (On the coalgebra side of the house there are
anamorphisms,apomorphisms,and all sorts of other beasts for
effectively generating covariant functors)

这就是我寻求的力量.

我正在努力解决这个问题并且真的想要一些帮助吗?现在我已经在scalaz中实现了InvariantFunctor,所以我知道这不是一个傻瓜差事.

我可以在这里轻推方向吗?我想尽可能多的细节,所以,坚持下去.

解决方法

阅读链接的帖子看起来像你需要:

trait CataDep[T,F[_]]

abstract class Cata[F[_],T](implicit e: CataDep[T,F]) {
   def cata[A]: (F[A] => A) => T => A
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读