sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
358 stars 73 forks source link

Question : how can I use title ? #165

Closed OlivierSohn closed 6 years ago

OlivierSohn commented 6 years ago

I couldn't figure out how to use title:

{-# LANGUAGE OverloadedStrings #-}

import Clay

mkCss :: Css
mkCss = do
  ".overlay" ? do
    title ("my title" :: String) -- this is the added line
    position absolute
    width $ pct 100
    height $ pct 100
    zIndex 1

    display none
    backgroundColor $ rgba 239 239 255 0.05

gives the following error:

/Users/Olivier/Dev/hs.hamazed/imj-profile/src/Imj/Profile/Render/Clay.hs:40:5: error:
    • No instance for (Data.String.IsString
                         (String -> Clay.Stylesheet.StyleM a0))
        arising from a use of ‘title’
        (maybe you haven't applied a function to enough arguments?)
    • In a stmt of a 'do' block: title ("my title" :: String)
      In the second argument of ‘(?)’, namely
        ‘do title ("my title" :: String)
            position absolute
            width $ pct 100
            height $ pct 100
            ....’
      In a stmt of a 'do' block:
        ".overlay"
          ? do title ("my title" :: String)
               position absolute
               width $ pct 100
               height $ pct 100
               ....
   |
40 |     title ("my title" :: String)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Removing the title line works ok.

Thanks!

RamiroPastor commented 6 years ago

title is a polymorphic constant, that is, it takes no arguments.

OlivierSohn commented 6 years ago

Thanks!