Question

this is a re-post of my original question that I asked on the yesod mailing list (please see http://groups.google.com/group/yesodweb/browse_thread/thread/934c4141fc615cb) in an attempt to get a faster response.

I am trying to figure out whether it is possible to generate a <link> with the type attribute that corresponds to the MIME type sent by the HTTP handler that serves the favicon file.

so far I have this link:

<link rel="icon" href=@{FaviconR} sizes="32x32" type="image/png">
and this handler:
getFaviconR :: Handler ()
getFaviconR = sendFile "image/png" "config/favicon.png"
I am looking for a way to make sure that the code compiles only if getFaviconR and <link> have the same MIME type.

I realize of course that I can omit type attribute from the link altogether and rely on the client to figure out the type, but think of it as a theoretical question.

I am new to Haskell, so may be I am asking for something impossible. no?

Was it helpful?

Solution

I think the easiest thing to do here is to define the image type in a separate variable and use it in both places.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top