小编IDo*_*OOP的帖子

IPFS:如何将文件添加到现有文件夹?

给定一个相当大的文件夹,它已被推送到网络,并在本地删除.如何将文件添加到该文件夹​​,而无需重新下载整个文件夹呢?

ipfs

15
推荐指数
3
解决办法
5093
查看次数

定义自己的Functor

我一直试图理解Funask在Haskell中的含义,为此我想要一个Functor的例子,没有任何其他属性.

我想出的工作实例是

data MyFunctor a b = MyFunctor a b deriving Show
instance Functor (MyFunctor a) where
  fmap g (MyFunctor a b) = MyFunctor a $ g (b)
Run Code Online (Sandbox Code Playgroud)

我猜这是一个半实用的Functor,因为左值可以安全地存储,而正确的值操作.然后我希望在操作之前将左值替换为正确的值.以便...

Main> fmap (+2) MyFunctor 2 5
MyFunctor 5 7
Run Code Online (Sandbox Code Playgroud)

但是,更改实例声明以执行此操作会产生错误.

data MyFunctor a b = MyFunctor a b deriving Show
instance Functor (MyFunctor a) where
  fmap g (MyFunctor a b) = MyFunctor b $ g (b)
Run Code Online (Sandbox Code Playgroud)

我不明白,或知道搜索什么找到一个类似的足够的问题来帮助我.

C:\Haskell\func.hs:3:28: error:
    * Couldn't match type `a1' with `a'
      `a1' is a rigid type …
Run Code Online (Sandbox Code Playgroud)

haskell types functor instances

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

标签 统计

functor ×1

haskell ×1

instances ×1

ipfs ×1

types ×1