The Pan# User Manual
top | back | next
7 Pan# For Haskell Programmers
One way to look at Pan is that it is a simplified implementation of
Haskell. This section gives experienced Haskell programmers a quick
overview of Pan.
Pan# does not allow new user-defined data types, only type synonyms.
Only tuples are available for data structuring. Operations cannot be
overloaded.
7.1 Haskell Features Missing in Pan#
- User-definable infix operators.
An identifier can be converted into an operator but there is no way to
assign a precedence other that 9 (left associative) to the operator.
- Sections.
- case expressions.
- Complex numbers.
- General looping. All loops must be statically unrollable.
- Selective import / export in modules.
7.2 Extensions / Incompatibilities
Pan# extends Haskell in a number of ways. These extensions include:
- Connections (binds in let statements): these are a
manifestation of the UI monad in the original Pan. Read code
such as
let x <- foo
y = bar
z <- blah
in baz
as the following:
do x <- foo
let y = bar
z <- blah
return baz
Unlike the normal Haskell "do", the monadic binding in Pan# are
fully recursive.
The main module (but no other) has an implicit "monadic let" in it,
allowing binds in the top level definitions.
- Type coercion: Pan# coerces the type a to
Framed a where needed. This "implicit return" allows the
user to use function such as beside on pictures instead of
framed pictures. The MFramed type is really a multi-parameter type
class, as follows:
class MFramed a b | a -> b where
frameIt :: a -> b
instance MFramed (Framed a) a where
frameIt = id
instance MFramed T T where -- for all types T except Framed
frameIt x = return x
A signature such as
beside :: MFramed ImageC -> MFramed ImageC -> Framed ImageC
would be as follows in Haskell:
beside :: (MFramed a ImageC, MFramed b ImageC) => a -> b -> Framed ImageC
- Views: the dual polar / cartesian views of points are not
supported in Haskell. This is currently the only view in the system.
- Variables can start with upper case letters.
The Pan# User Manual
top | back | next |
March, 2004