Version 10 (modified by benl, 5 years ago)


< Main

Disciple vs Haskell

These are some syntactic differences that tend to trip up Haskell programmers when they first start with Disciple.

Evaluation Order


fun :: Int -> Int
fun x = x + z
 where  y = g x
        z = 3 + y

but not:

fun :: Int -> Int
fun x = x + z
 where  z = 3 + y
        y = g x


For let and where expressions, all the bindings are evaluated in-order, before moving to the body.

The (.) operator

We use (.) for projection instead of function composition. If you want to compose two functions then use ($), or suggest a good replacement for (.) on the mailing lists.

Death to [Char]

In the Disciple prelude, strings are defined as append-lists of bytestrings. This provides sane complexities to the common operations of constructing and printing strings, with respect to the regular Haskell ones. For this reason you need to use the string append operator (%) to append lists, instead of the list append operator (++). If you really want a list of characters then use charListOfString :: String -> [Char] defined in Data.List.

No Dictionary Passing

Dictionary passing for type classes isn't implemented yet, but we plan to in the medium term (within 12 months). You can still define new classes and instances, but each method call must be resolved to its instance at the point of use. In practice this means that you can't write functions with class contexts. For example, this is ok:

showTwoInts :: (Int, Int)  -> String
showTwoInts (x, y) = "you've got a " % show x % " and a " % show y

but this doesn't work:

showTwoThings :: Show a => (a, a) -> String