Difference between revisions of "FP Laboratory 1"

From Marek Běhálek Wiki
Jump to navigation Jump to search
Line 19: Line 19:
 
doubleMe x = x * x
 
doubleMe x = x * x
  
plus x y  = x + y
+
plus x y  = x + y + 'a'
 
</syntaxhighlight >
 
</syntaxhighlight >
 
<translate>
 
<translate>
 
+
It should report a problem in function <code>plus</code> (you can not use <code>+</code> with letter, it can be repaired by removing <code>+ 'a'</code>). Report from VS Code is refreshed whenever the source file is saved on disk.
 
</translate>
 
</translate>

Revision as of 12:19, 28 August 2019

Working environment

Using the installation guide from Functional programming prepare your working environment.

How to verify it is working?

  • Run ghci from the command line. it will start GHC Interpreter, the output should be something like this:
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude>
  • If you write expression, for example 1+2*3, it should be evaluated. You can close this interpreter by typing :q.
  • Open Visual Studio Code, create a file simple.hs and put there following lines of code:
doubleMe x = x * x

plus x y  = x + y + 'a'

It should report a problem in function plus (you can not use + with letter, it can be repaired by removing + 'a'). Report from VS Code is refreshed whenever the source file is saved on disk.