Friday 29 April 2016

Haskell: :set : Change settings

By using ‘:set’ command we can change some of the default behaviors of the Haskell Environment.

Following are the commands to change settings.
Command
Description
:set <option> ...
Set options
:seti <option> ...
Set options for interactive evaluation only
:set args <arg> ...
Set the arguments returned by System.getArgs
:set prog <progname>
Set the value returned by System.getProgName
:set prompt <prompt>  
Set the prompt used in GHCi
:set prompt2 <prompt>      
Set the continuation prompt used in GHCi

:set editor <cmd>
Set the command used for :edit

Following are the various options used by both ‘:set’ ‘:unset’ commands.
Option
Description
+m
Allow multiline commands
+r
Revert top-level expressions after each evaluation
+s
Print timing/memory stats after each evaluation
+t
Print type after evaluation
-<flags>     
Most GHC command line flags can also be set here. (eg. -v2, -XFlexibleInstances, etc.)

Change the GHCi prompt
By using ‘:set prompt promptName’ command, you can change the prompt name used in GHCi.

Prelude> :set prompt ptr>
ptr>
ptr>let str1 = "Hello World"
ptr>putStrLn str1
Hello World
ptr>


By using various options of :set command, you can add extra information while displaying variables.

ptr>let str1 = "Hello World"
ptr>str1
"Hello World"
ptr>
ptr>:set +t +s
ptr>
ptr>str1
"Hello World"
it :: [Char]
(0.00 secs, 514,752 bytes)
ptr>

‘:set +t +s’ add type information of the variable,  timing/memory stats of variable after every evaluation.

References


Previous                                                 Next                                                 Home

No comments:

Post a Comment