Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Copied F# code from one module to another and it broke

I ran "dotnet new giraffe."

Then I tried moving the Views module into a Views.fs file. The same code that compiled without error in Program.fs now has an error message in Views.fs:

GiraffeApp/Views.fs(9,20): error FS0003: This value is not a function and cannot be applied. 

It happens at _rel in this function:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

let layout (content: XmlNode list) =
    html [] [
        head [] [
            title []  [ encodedText "GiraffeApp" ]
            link [ _rel  "stylesheet"
                    _type "text/css"
                    _href "/main.css" ]
        ]
        body [] content
    ]

Full code change is here:
https://github.com/surferjeff/blazor-compared/commit/d6f76bfacf1853d1561b8533666fab24b0f89f3f

The error message is telling me _rel is not a function. Ok, but I don’t know what _rel is. I searched the Giraffe repo for _rel and found no instances of that string in the code. I don’t understand why it expects _rel to be a function in this context but not when the code was in Program.cs.

>Solution :

The problem is with your whitespace. By indenting _type under _rel you’ve made the compiler think that you’re invoking a function. Instead of this:

            link [ _rel  "stylesheet"
                    _type "text/css"       // <- incorrect indentation
                    _href "/main.css" ]    // <- incorrect indentation

You want this:

            link [ _rel  "stylesheet"
                   _type "text/css"
                   _href "/main.css" ]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading