0

In a yesod application, I want to create URL attributes for a graph that will be rendered by graphviz , and I want to use interpolation. Ideally,

graphToDot nonClusteredParams { fmtNode = \ (n,l) -> 
     [ URL [whamlet| @{MyRoute ...} |]
   } g

Of course, the types don't match:

  • attribute of URL is pure Text, but whamlet is monadic (widget)
  • when I replace by shamlet, type is fine, but it cannot interpolate: URL interpolation used, but no URL renderer provided

Is there an easy way to solve this?

Ganesh Pandey
  • 5,216
  • 1
  • 33
  • 39
d8d0d65b3f7cf42
  • 2,597
  • 15
  • 28

1 Answers1

1

This works: get the render function (in the monad), and apply (in pure code)

render <- getUrlRender 
let d = graphToDot ... 
     [ URL $ render $ MyRoute ... ]

I found this here, where a similar problem is solved: https://github.com/yesodweb/yesod/wiki/Using-type-safe-urls-from-inside-javascript

d8d0d65b3f7cf42
  • 2,597
  • 15
  • 28