Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

specifying favicon in a type-safe manner in yesod

Tags:

haskell

yesod

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?

like image 437
akonsu Avatar asked Oct 25 '22 01:10

akonsu


1 Answers

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

like image 141
Michael Snoyman Avatar answered Nov 04 '22 00:11

Michael Snoyman