Changes between Version 8 and Version 9 of Language/VersusHaskell
- Timestamp:
- 06/17/10 04:05:57 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Language/VersusHaskell
v8 v9 5 5 These are some syntactic differences that tend to trip up Haskell programmers when they first start with Disciple. 6 6 7 * Disciple uses strict / call-by-value as the default evaluation order. This implies that bindings in let and where expressions must be written in dependency order. For example, you can write: 7 === Evaluation Order === 8 Disciple uses strict / call-by-value as the default evaluation order. This implies that bindings in let and where expressions must be written in dependency order. For example, you can write: 8 9 9 {{{10 {{{ 10 11 fun :: Int -> Int 11 12 fun x = x + z 12 13 where y = g x 13 14 z = 3 + y 14 }}}15 }}} 15 16 16 but not:17 but not: 17 18 18 {{{19 {{{ 19 20 fun :: Int -> Int 20 21 fun x = x + z 21 22 where z = 3 + y 22 23 y = g x 23 }}} 24 This doesn't work because the bindings for {{{y}}} and {{{z}}} are in the "wrong" order. 24 }}} 25 25 26 For {{{let}}} and {{{where}}} expressions, all the bindings are evaluated in-order, before moving to the body.26 This doesn't work because the bindings for {{{y}}} and {{{z}}} are in the "wrong" order. 27 27 28 * 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.28 For {{{let}}} and {{{where}}} expressions, all the bindings are evaluated in-order, before moving to the body. 29 29 30 === The (.) operator === 31 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. 32 33 === Death to [Char] === 34 In the Disciple prelude, strings are defined using an append-list 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`. 35 36 === No Dictionary Passing === 37 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: 38 39 {{{ 40 showTwoInts :: (Int, Int) -> String 41 showTwoInts (x, y) = "you've got a " % show x % " and a " % show y 42 }}} 43 44 but this doesn't work: 45 46 {{{ 47 showTwoThings :: Show a => (a, a) -> String 48 showTwoThings (x, y) = "you've got a " % show x % " and a " % show y 49 }}} 50 51 52 53 54
