Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 如何协调“hakyll”和“hakyll”图像之间的类型`_Haskell_Hakyll - Fatal编程技术网

Haskell 如何协调“hakyll”和“hakyll”图像之间的类型`

Haskell 如何协调“hakyll”和“hakyll”图像之间的类型`,haskell,hakyll,Haskell,Hakyll,我正在尝试使用并实现一个来自hakyll images自述文件的示例,该自述文件执行图像缩放,我需要这样做。对于给定的示例,类型不统一,我正在寻求如何继续的建议 下面是一个失败的例子 import Hakyll import Hakyll.Images ( loadImage , scaleImageCompiler ) main = hakyll $ do --

我正在尝试使用并实现一个来自
hakyll images
自述文件的示例,该自述文件执行图像缩放,我需要这样做。对于给定的示例,类型不统一,我正在寻求如何继续的建议

下面是一个失败的例子

import Hakyll
import Hakyll.Images        ( loadImage
                            , scaleImageCompiler
                            )
main = hakyll $ do
    -- Scale images to fit within a 600x400 box
    -- Aspect ratio will be preserved
    match "images/*" $ do
        route idRoute
        compile $ loadImage
            >>= scaleImageCompiler 600 400
试图编译时出现错误:

site.hs:12:9: error:
    • No instance for (Writable
                         hakyll-images-0.3.1:Hakyll.Images.Common.Image)
        arising from a use of ‘compile’
    • In a stmt of a 'do' block:
        compile $ loadImage >>= scaleImageCompiler 600 400
      In the second argument of ‘($)’, namely
        ‘do route idRoute
            compile $ loadImage >>= scaleImageCompiler 600 400’
      In a stmt of a 'do' block:
        match "images/*"
          $ do route idRoute
               compile $ loadImage >>= scaleImageCompiler 600 400
   |
12 |         compile $ loadImage >>= scaleImageCompiler 600 400
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
该错误是因为由
loadImage
定义的类型
Image
,是
compile
所要求的类型类
writeable
的实例。从hackage文档中复制的
hakyll
hakyll images
中使用的函数类型如下所示

    route :: Routes -> Rules ()
    idRoute :: Routes
    compile :: (Binary a, Typeable a, Writable a) => Compiler (Item a) -> Rules ()
    loadImage :: Compiler (Item Image)
    scaleImageCompiler :: Width -> Height -> Item Image -> Compiler (Item Image)
Image
在中定义为
type Image=Image\uu.ByteString
。 我不确定什么是
图像
;其定义未在该文档中链接

在任何情况下,
hakyll images
自述文件中的示例似乎都没有编译,因为
Image
不是
可写的
的实例。我想知道是否在某个时候,
hakyll-images
包与
hakyll
不同步,导致示例不再编译

这个评估似乎正确吗? 您有什么建议,我可以如何找到解决方案

我正在考虑:

  • 通过为
    Image
    添加一个
    writeable
    实例来更新
    hakyll图像
  • 使用其他函数集或函数组合来执行保持纵横比的图像缩放
  • 挖沟
    hakyll图像
    ,并找到其他方法缩放图像

这种行为是hakyll images 0.3.1版本中的一个bug。随后在hakyll图像0.4及以上中对其进行了修复。只需更新到最新版本即可解决此问题

这是一个严重的疏忽,已经添加了测试,这样就不会再发生这种情况


如果您想自己实现这些实例,您可以看看它是如何实现的。

这种行为是hakyll images 0.3.1版本中的一个bug。随后在hakyll图像0.4及以上中对其进行了修复。只需更新到最新版本即可解决此问题

这是一个严重的疏忽,已经添加了测试,这样就不会再发生这种情况


如果您想自己实现这些实例,可以看看是如何实现的。

啊,我知道我使用的是较旧的版本,它在最新版本中得到了修复。非常感谢。啊,我知道我用的是旧版本,最新版本已经修复了。非常感谢。