asop
2012-11-25
Hi, suppose I am looking at the Outline window in the Haskell perspective. Then if I have the following piece of code :
y = 10 main = do print y
Then the value y appears as "f(.) y" in the outline window. If it is a value, then why is the outline window showing it as a function? Thanks
JP Moresmau
2012-11-25
Because there is no difference, really, in Haskell. A value is a function with no parameter, a constant function if you like, and tthe difference is somewhat subtle (for example: getCurrentTime is a function with no argument but returning always a different value, so a function with no argument is not always a value…). The code we use to generate the outline (Haskell-src-exts) does not differentiate.
asop
2012-11-25
But in theory it should be possible to differentiate between the two right? Because we know that if it is a value type then the :t command in ghci yields something with no arrow ->, whereas if it is a function then there exists an arrow -> in the output of :t. Or have I got that wrong? Thanks
JP Moresmau
2012-11-25
getCurrentTime has type IO(). It contains no -> in the type. Is it a value? Or a function?
asop
2012-11-25
Actually I just realised that and was rushing back to the forum to correct myself but it seems you beat me to it!:)
So if you made the statement that anything which has :
a)type IO()
b)Arrow in type declaration
is a function, and anything else is a value type, then would that work? Thanks
JP Moresmau
2012-11-25
You can have any type of monad transformer wrapping IO, so you'll need a type analysis to decide if the value is constant or not, I believe, so it would add complexify the outline generation…