How to reconcile types between `hakyll` and `hakyll-images`
I am trying to use hakyll and hakyll-images to implement an example from the hakyll-images Readme which performs an image scaling as I will need to do. The types do not unify for the given example and I am seeking advice on how to proceed.
The failing example from the hakyll-images Readme is below.
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
Attempting to compile gives an error:
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The error is because type Image, defined by loadImage, is required by compile to be an instance of typeclass Writable. The types of the functions used from hakyll and hakyll-images, copied from the hackage documentation, are shown below.
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 is defined in hakyll-images as type Image = Image_ ByteString.
I am not sure what Image_ is; its definition is not linked in that documentation for the Hakyll.Images module.
In any case, it appears that the example from hakyll-images's Readme does not compile due to Image not being an instance of Writable. I'm wondering if perhaps the hakyll-images package became out-of-sync with hakyll at some point leading to the example no longer compiling.
Does this assessment seem correct?
What do you suggest for how might I approach a solution?
I am considering:
- Updating
hakyll-imagesby somehow adding aWritableinstance forImage. - Using some other set or combination of functions to perform the aspect-ratio-preserving image scalings.
- Ditching
hakyll-imagesand finding some other way to scale the images.
haskell hakyll
add a comment |
I am trying to use hakyll and hakyll-images to implement an example from the hakyll-images Readme which performs an image scaling as I will need to do. The types do not unify for the given example and I am seeking advice on how to proceed.
The failing example from the hakyll-images Readme is below.
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
Attempting to compile gives an error:
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The error is because type Image, defined by loadImage, is required by compile to be an instance of typeclass Writable. The types of the functions used from hakyll and hakyll-images, copied from the hackage documentation, are shown below.
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 is defined in hakyll-images as type Image = Image_ ByteString.
I am not sure what Image_ is; its definition is not linked in that documentation for the Hakyll.Images module.
In any case, it appears that the example from hakyll-images's Readme does not compile due to Image not being an instance of Writable. I'm wondering if perhaps the hakyll-images package became out-of-sync with hakyll at some point leading to the example no longer compiling.
Does this assessment seem correct?
What do you suggest for how might I approach a solution?
I am considering:
- Updating
hakyll-imagesby somehow adding aWritableinstance forImage. - Using some other set or combination of functions to perform the aspect-ratio-preserving image scalings.
- Ditching
hakyll-imagesand finding some other way to scale the images.
haskell hakyll
add a comment |
I am trying to use hakyll and hakyll-images to implement an example from the hakyll-images Readme which performs an image scaling as I will need to do. The types do not unify for the given example and I am seeking advice on how to proceed.
The failing example from the hakyll-images Readme is below.
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
Attempting to compile gives an error:
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The error is because type Image, defined by loadImage, is required by compile to be an instance of typeclass Writable. The types of the functions used from hakyll and hakyll-images, copied from the hackage documentation, are shown below.
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 is defined in hakyll-images as type Image = Image_ ByteString.
I am not sure what Image_ is; its definition is not linked in that documentation for the Hakyll.Images module.
In any case, it appears that the example from hakyll-images's Readme does not compile due to Image not being an instance of Writable. I'm wondering if perhaps the hakyll-images package became out-of-sync with hakyll at some point leading to the example no longer compiling.
Does this assessment seem correct?
What do you suggest for how might I approach a solution?
I am considering:
- Updating
hakyll-imagesby somehow adding aWritableinstance forImage. - Using some other set or combination of functions to perform the aspect-ratio-preserving image scalings.
- Ditching
hakyll-imagesand finding some other way to scale the images.
haskell hakyll
I am trying to use hakyll and hakyll-images to implement an example from the hakyll-images Readme which performs an image scaling as I will need to do. The types do not unify for the given example and I am seeking advice on how to proceed.
The failing example from the hakyll-images Readme is below.
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
Attempting to compile gives an error:
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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The error is because type Image, defined by loadImage, is required by compile to be an instance of typeclass Writable. The types of the functions used from hakyll and hakyll-images, copied from the hackage documentation, are shown below.
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 is defined in hakyll-images as type Image = Image_ ByteString.
I am not sure what Image_ is; its definition is not linked in that documentation for the Hakyll.Images module.
In any case, it appears that the example from hakyll-images's Readme does not compile due to Image not being an instance of Writable. I'm wondering if perhaps the hakyll-images package became out-of-sync with hakyll at some point leading to the example no longer compiling.
Does this assessment seem correct?
What do you suggest for how might I approach a solution?
I am considering:
- Updating
hakyll-imagesby somehow adding aWritableinstance forImage. - Using some other set or combination of functions to perform the aspect-ratio-preserving image scalings.
- Ditching
hakyll-imagesand finding some other way to scale the images.
haskell hakyll
haskell hakyll
edited Jan 20 at 6:48
mherzl
asked Jan 20 at 6:42
mherzlmherzl
1,3501326
1,3501326
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This behavior is a bug that made its way into the hakyll-images 0.3.1 release. It was fixed subsequently in hakyll-images 0.4 and above. Simply update to the latest version to get rid of this problem.
This was a gross oversight and tests have been added such that this will not happen again.
If you wanted to implement the instances yourself, you can take a look at how it is done here.
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54274208%2fhow-to-reconcile-types-between-hakyll-and-hakyll-images%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This behavior is a bug that made its way into the hakyll-images 0.3.1 release. It was fixed subsequently in hakyll-images 0.4 and above. Simply update to the latest version to get rid of this problem.
This was a gross oversight and tests have been added such that this will not happen again.
If you wanted to implement the instances yourself, you can take a look at how it is done here.
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
add a comment |
This behavior is a bug that made its way into the hakyll-images 0.3.1 release. It was fixed subsequently in hakyll-images 0.4 and above. Simply update to the latest version to get rid of this problem.
This was a gross oversight and tests have been added such that this will not happen again.
If you wanted to implement the instances yourself, you can take a look at how it is done here.
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
add a comment |
This behavior is a bug that made its way into the hakyll-images 0.3.1 release. It was fixed subsequently in hakyll-images 0.4 and above. Simply update to the latest version to get rid of this problem.
This was a gross oversight and tests have been added such that this will not happen again.
If you wanted to implement the instances yourself, you can take a look at how it is done here.
This behavior is a bug that made its way into the hakyll-images 0.3.1 release. It was fixed subsequently in hakyll-images 0.4 and above. Simply update to the latest version to get rid of this problem.
This was a gross oversight and tests have been added such that this will not happen again.
If you wanted to implement the instances yourself, you can take a look at how it is done here.
answered Jan 22 at 1:46
Laurent René de CotretLaurent René de Cotret
361
361
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
add a comment |
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
Ah, I see I was using an older version and it is fixed in the latest. Thank you!
– mherzl
Jan 22 at 2:42
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54274208%2fhow-to-reconcile-types-between-hakyll-and-hakyll-images%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown