Compiling to Executable

You can compile programs using Euterpea to executable using ghc rather than GHCi. The executable produced will be for your OS (i.e. a Windows exe if compiled on Windows).

Here’s an example of how to make a small executable First, create a file called Main.lhs and add the following code to it:

> module Main where
> import Euterpea
> main :: IO ()
> main = play $ c 4 qn

This program will play a single note and then terminate. You can compile it as follows

ghc Main.lhs -o YourExeFileName

On Windows, you should use an executable file name ending in .exe.

Once compiled, you can run the executable either by double-clicking it or by calling it from a terminal or from powershell as follows:

./YourExeFileName

Compiling HSoM’s MUIs

Compiling to executable is required for using HSoM’s MUIs on Mac OS (they usually work in GHCi with Windows). You can check whether compiled MUIs work for you by creating a Main.lhs with the following code:

> module Main where
> import HSoM.Examples.MUIExamples2
> main = bifurcate

Compile it using the following command:

ghc Main.lhs -o Bifurcate

Then run it using:

./Bifurcate