← 返回命令列表

Linux command

runghc 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Run Haskell script

runghc [script.hs]

Run with arguments

runghc [script.hs] [arg1] [arg2]

Specify GHC version

runghc-[8.10] [script.hs]

With GHC options

runghc -- -O2 [script.hs]

说明

runghc runs Haskell source files directly without a separate compilation step, making it ideal for scripting and quick prototyping. It invokes GHC (Glasgow Haskell Compiler) behind the scenes to compile the program to a temporary location and execute it immediately, providing a scripting-like experience for Haskell code. The tool supports shebang lines (#!/usr/bin/env runghc), enabling Haskell files to be used as executable scripts. Command-line arguments after the filename are passed to the Haskell program, and GHC options can be specified before a -- separator. The synonym runhaskell is also available.

参数

--
Separator for GHC options.
-f _file_
Use different GHC.
--help
Show help.
--version
Show version.

FAQ

What is the runghc command used for?

runghc runs Haskell source files directly without a separate compilation step, making it ideal for scripting and quick prototyping. It invokes GHC (Glasgow Haskell Compiler) behind the scenes to compile the program to a temporary location and execute it immediately, providing a scripting-like experience for Haskell code. The tool supports shebang lines (#!/usr/bin/env runghc), enabling Haskell files to be used as executable scripts. Command-line arguments after the filename are passed to the Haskell program, and GHC options can be specified before a -- separator. The synonym runhaskell is also available.

How do I run a basic runghc example?

Run `runghc [script.hs]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -- do in runghc?

Separator for GHC options.