Skip to main content
Commonmark migration
Source Link

#Haskell

Haskell

There are a couple of possibilities here.

Boring idea #1: Define main to do nothing. Now no matter what other code you write, it can never execute. (Unless you manually run it from the REPL.)

Boring idea #2: Define a module with no public exports. Now no matter what other code your write, it can never execute.

Interesting idea: Disable all imports.

module Fubar where
import Prelude ()
foo = foo
-- More code here.

Now you can define functions which are visible and can be run... but they can't do anything. All standard Haskell types and functions are now hidden. (With the exception of a few things really deeply hard-wired into the language.)

Most particularly, you cannot perform any I/O whatsoever. You also cannot do machine-precision arithmetic. (Since Int, Double, etc are now undefined.)

You can still write lambda-calculus functions that do perform some real computation though. You just can't get any data into or out of the thing. But you could of course write another, separate module that calls the Fubar module above and does I/O on its behalf (thus proving that the code does execute and does do stuff).

Some subtleties:

  • The dummy foo = foo declaration is needed to prevent anybody adding additional imports. (Imports cannot appear after declarations.)

  • There are various non-standard Haskell language extensions that would enable you to climb out of this situation. But language extensions have to be switched on with a compiler pragma at the top of the file. (Or with a command-line switch to the compiler. I can't really prevent that one!)

#Haskell

There are a couple of possibilities here.

Boring idea #1: Define main to do nothing. Now no matter what other code you write, it can never execute. (Unless you manually run it from the REPL.)

Boring idea #2: Define a module with no public exports. Now no matter what other code your write, it can never execute.

Interesting idea: Disable all imports.

module Fubar where
import Prelude ()
foo = foo
-- More code here.

Now you can define functions which are visible and can be run... but they can't do anything. All standard Haskell types and functions are now hidden. (With the exception of a few things really deeply hard-wired into the language.)

Most particularly, you cannot perform any I/O whatsoever. You also cannot do machine-precision arithmetic. (Since Int, Double, etc are now undefined.)

You can still write lambda-calculus functions that do perform some real computation though. You just can't get any data into or out of the thing. But you could of course write another, separate module that calls the Fubar module above and does I/O on its behalf (thus proving that the code does execute and does do stuff).

Some subtleties:

  • The dummy foo = foo declaration is needed to prevent anybody adding additional imports. (Imports cannot appear after declarations.)

  • There are various non-standard Haskell language extensions that would enable you to climb out of this situation. But language extensions have to be switched on with a compiler pragma at the top of the file. (Or with a command-line switch to the compiler. I can't really prevent that one!)

Haskell

There are a couple of possibilities here.

Boring idea #1: Define main to do nothing. Now no matter what other code you write, it can never execute. (Unless you manually run it from the REPL.)

Boring idea #2: Define a module with no public exports. Now no matter what other code your write, it can never execute.

Interesting idea: Disable all imports.

module Fubar where
import Prelude ()
foo = foo
-- More code here.

Now you can define functions which are visible and can be run... but they can't do anything. All standard Haskell types and functions are now hidden. (With the exception of a few things really deeply hard-wired into the language.)

Most particularly, you cannot perform any I/O whatsoever. You also cannot do machine-precision arithmetic. (Since Int, Double, etc are now undefined.)

You can still write lambda-calculus functions that do perform some real computation though. You just can't get any data into or out of the thing. But you could of course write another, separate module that calls the Fubar module above and does I/O on its behalf (thus proving that the code does execute and does do stuff).

Some subtleties:

  • The dummy foo = foo declaration is needed to prevent anybody adding additional imports. (Imports cannot appear after declarations.)

  • There are various non-standard Haskell language extensions that would enable you to climb out of this situation. But language extensions have to be switched on with a compiler pragma at the top of the file. (Or with a command-line switch to the compiler. I can't really prevent that one!)

Source Link

#Haskell

There are a couple of possibilities here.

Boring idea #1: Define main to do nothing. Now no matter what other code you write, it can never execute. (Unless you manually run it from the REPL.)

Boring idea #2: Define a module with no public exports. Now no matter what other code your write, it can never execute.

Interesting idea: Disable all imports.

module Fubar where
import Prelude ()
foo = foo
-- More code here.

Now you can define functions which are visible and can be run... but they can't do anything. All standard Haskell types and functions are now hidden. (With the exception of a few things really deeply hard-wired into the language.)

Most particularly, you cannot perform any I/O whatsoever. You also cannot do machine-precision arithmetic. (Since Int, Double, etc are now undefined.)

You can still write lambda-calculus functions that do perform some real computation though. You just can't get any data into or out of the thing. But you could of course write another, separate module that calls the Fubar module above and does I/O on its behalf (thus proving that the code does execute and does do stuff).

Some subtleties:

  • The dummy foo = foo declaration is needed to prevent anybody adding additional imports. (Imports cannot appear after declarations.)

  • There are various non-standard Haskell language extensions that would enable you to climb out of this situation. But language extensions have to be switched on with a compiler pragma at the top of the file. (Or with a command-line switch to the compiler. I can't really prevent that one!)