Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (28 sloc) 0.982 kb
ef4abad @tomlokhorst Example of how partial application fails (see `epicfail`)
authored
1 {-# LANGUAGE NoImplicitPrelude, RankNTypes #-}
8b57a9e @tomlokhorst Initial checkin
authored
2
3 module Main where
4
5 import AwesomePrelude
6 import HaskellPrelude
7 import JsPrelude
8
9 import Prelude (Int, fromInteger)
ef4abad @tomlokhorst Example of how partial application fails (see `epicfail`)
authored
10 import qualified Prelude as P
8b57a9e @tomlokhorst Initial checkin
authored
11
12
41c088e @tomlokhorst Clearified example.
authored
13 -- Switch between these two types to see the AwesomePrelude in action!
14
15
16 -- test :: Js JsBool
17 test :: P.Bool
8b57a9e @tomlokhorst Initial checkin
authored
18 test = not false && false || true
19
41c088e @tomlokhorst Clearified example.
authored
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 listy :: [Int]
35 listy = 3 `cons` (4 `cons` nil)
36
e46e951 @tomlokhorst Renamed if_, maybee, eitherr
authored
37 bool' :: a -> a -> P.Bool -> a
38 bool' x y b = if b then x else y
ef4abad @tomlokhorst Example of how partial application fails (see `epicfail`)
authored
39
40 f :: (forall a. a -> a -> b -> a) -> a -> b -> a
41 f g a b = g a a b
42
e46e951 @tomlokhorst Renamed if_, maybee, eitherr
authored
43 ok = f bool'
ef4abad @tomlokhorst Example of how partial application fails (see `epicfail`)
authored
44 -- epicfail = f bool
45
6b41fe6 @tomlokhorst Cleaned up examples, there isn't a Num JsNumber instance, so JavaScript ...
authored
46 hi = maybe false not
47 (just true :: P.Maybe P.Bool)
48 -- (just true :: JsC1 JsMaybe (Js JsBool))
8b57a9e @tomlokhorst Initial checkin
authored
49
6b41fe6 @tomlokhorst Cleaned up examples, there isn't a Num JsNumber instance, so JavaScript ...
authored
50 yo = either (P.* 5) (P.const 2)
51 (right false :: P.Either P.Int P.Bool)
52 -- (right false :: JsC2 JsEither (Js JsNumber) (Js JsBool))
8b57a9e @tomlokhorst Initial checkin
authored
53
6b41fe6 @tomlokhorst Cleaned up examples, there isn't a Num JsNumber instance, so JavaScript ...
authored
54 ah = tuple2 (\x y -> x && P.const false y)
55 (ctuple2 true 3 :: (,) P.Bool P.Int)
56 -- (ctuple2 true 3 :: JsC2 JsTuple2 (Js JsBool) (Js JsNumber))
8b57a9e @tomlokhorst Initial checkin
authored
57
Something went wrong with that request. Please try again.