Defining symbology as a safe type in yesod

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

I am trying to figure out if it is possible to generate a <link> with a type attribute that matches 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 ensure that code compiles only if getFaviconR and <link> are of the same MIME type.

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

I'm new to Haskell, so maybe I'm asking for something impossible. no?

+4
source share
1 answer

I think the easiest way here is to determine the type of image in a separate variable and use it in both places.

+3
source

All Articles