Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Haskell: Enable warnings at GHCi prompt

By calling ‘:set –Wall’ at Ghci Prompt, you can Enable Warnings at GHCi prompt.


Fact.hs
factorial :: Integer -> Integer
factorial n
| n == 0 = 1
| n /= 0 = n * factorial (n-1)


Load above program into GHCi prompt.
Prelude> :load Fact.hs 
[1 of 1] Compiling Main ( Fact.hs, interpreted )
Ok, modules loaded: Main.
*Main>


Now enable warnings using ‘:set –Wall’ command and reload Fact.hs.
*Main> :set -Wall
*Main>
*Main> :load Fact.hs
[1 of 1] Compiling Main ( Fact.hs, interpreted )

Fact.hs:2:1: Warning:
Pattern match(es) are non-exhaustive
In an equation for factorial: Patterns not matched: _
Ok, modules loaded: Main.

How to disable warnings?
Use ‘:set –w’ to disable warnings.


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Haskell: Enable warnings at GHCi prompt

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×