let double x = x...">

Does tryhaskell.org support definitions?

I am trying to use "let" to define an expression definition, but all I get is errors.

> let double x = x * x not an expression: `let double x = x * x' 

Is there a special command I have to use, or does the javascript compiler not support this function?

+6
source share
1 answer

Indeed, it does not support definitions; presumably because it is intended only as a basic introduction and probably does not support the state between the lines. As implied by using hint , it just evaluates the expressions. In addition, unlike GHCi, it does not try to perform IO actions (fortunately!) And just tries to print them (which fails because there is no Show instance in the IO actions).

You can, however, make let square x = x * x in square 42 in one line.

By the way, Try Haskell does not use the Haskell JavaScript compiler or anything like that; it communicates with the server to evaluate the entered expressions.

In general, this is a clear proof of concept and an excellent initial hook to interest people in Haskell, but for any real use, it will not do anything compared to something like GHCi.

+9
source

Source: https://habr.com/ru/post/905950/


All Articles