我想用
hakyll
和
hakyll-images
从中实现示例
哈基尔图像
自述文件,它按照我的需要执行图像缩放。对于给定的示例,类型并不统一,我正在寻求有关如何继续的建议。
失败的例子来自
hakyll-images
Readme
在下面。
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
错误是因为类型
Image
,由
loadImage
,是必需的
compile
作为typeclass的实例
Writable
. 从中使用的函数类型
哈基尔
和
哈基尔图像
如下所示。
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)
图像
定义在
hakyll-images
作为
type Image = Image_ ByteString
.
我不确定什么
Image_
在该文档中没有链接
Hakyll.Images
module
.
在任何情况下,该示例
哈基尔图像
的自述文件由于
图像
不是的实例
可写的
. 我想知道
哈基尔图像
包与不同步
哈基尔
在某种程度上导致示例不再编译。
这个评估看起来正确吗?
你建议我如何解决问题?
我正在考虑:
-
更新
哈基尔图像
通过添加
可写的
实例为
图像
.
-
使用其他一些函数集或函数组合来执行保持图像缩放的纵横比。
-
挖沟
哈基尔图像
找到其他方法来缩放图像。