You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quick Summary: Missing parenthesis of tuples in the type signature of a function, seemingly lead the parser to assume that something is between the signature and definition, instead of raising a syntax error or type mismatch.
SSCCE
moduleMainexposing (..)
importBrowserimportHtmlexposing (Html, div, text)
-- MAINmain =Browser.sandbox { init = init, update = update, view = view }-- UPDATEupdate:()->Model->Modelupdate _ model =
model
-- MODELtype alias Model=Intinit:Modelinit =3-- VIEWview:Model->Html()view model =
div [][text (Tuple.first (factorial model))]factorial:Int->String, Intfactorial i=if i <=1then ("1",1)else let
val = i *(Tuple.second (factorial (i -1)))in(String.fromInt val, val)
EXPECTING DEFINITION
Jump to problem
I just saw the type annotation for `factorial` so I was expecting to see its
definition here:
26| factorial : Int -> String, Int
^
Type annotations always appear directly above the relevant definition, without
anything else in between. (Not even doc comments!)
Here is a valid definition (with a type annotation) for reference:
greet : String -> String
greet name =
"Hello " ++ name ++ "!"
The top line (called a "type annotation") is optional. You can leave it off if
you want. As you get more comfortable with Elm and as your project grows, it
becomes more and more valuable to add them though! They work great as
compiler-verified documentation, and they often improve error messages!
The text was updated successfully, but these errors were encountered:
Quick Summary: Missing parenthesis of tuples in the type signature of a function, seemingly lead the parser to assume that something is between the signature and definition, instead of raising a syntax error or type mismatch.
SSCCE
Additional Details
Compiler output:
The text was updated successfully, but these errors were encountered: