Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 71 lines (43 sloc) 1.277 kB
ff2d94c @tomlokhorst Cleaned up Main example.
authored
1 {-# LANGUAGE
2 NoImplicitPrelude
3 , RankNTypes
4 #-}
8b57a9e @tomlokhorst Initial checkin
authored
5
6 module Main where
7
8 import AwesomePrelude
9 import HaskellPrelude
10 import JsPrelude
11
9cd320d Less string literals.
Sebastiaan Visser authored
12 import Prelude (Int)
ef4abad @tomlokhorst Example of how partial application fails (see `epicfail`)
authored
13 import qualified Prelude as P
8b57a9e @tomlokhorst Initial checkin
authored
14
15
ff2d94c @tomlokhorst Cleaned up Main example.
authored
16 -- Switch between these two types and run `test` to see the AwesomePrelude in action!
41c088e @tomlokhorst Clearified example.
authored
17
ed3dace @tomlokhorst Extended examples in Main
authored
18 fb :: Js JsBool -> Js JsBool
19 --fb :: P.Bool -> P.Bool
20 fb x = not x && false || true
41c088e @tomlokhorst Clearified example.
authored
21
ed3dace @tomlokhorst Extended examples in Main
authored
22 test = fb false
41c088e @tomlokhorst Clearified example.
authored
23
24
25
ed3dace @tomlokhorst Extended examples in Main
authored
26 --fEq :: Js JsBool -> Js JsBool
27 fEq :: P.Bool -> P.Bool
28 fEq x = x == not x
41c088e @tomlokhorst Clearified example.
authored
29
ed3dace @tomlokhorst Extended examples in Main
authored
30 test2 = fEq true
41c088e @tomlokhorst Clearified example.
authored
31
32
33
ed3dace @tomlokhorst Extended examples in Main
authored
34 --fNumEq :: Js JsNumber -> Js JsNumber -> Js JsBool
35 fNumEq :: P.Int -> P.Int -> P.Bool
36 fNumEq x y = x == y
41c088e @tomlokhorst Clearified example.
authored
37
ed3dace @tomlokhorst Extended examples in Main
authored
38 test3 = fNumEq 3 4
41c088e @tomlokhorst Clearified example.
authored
39
40
41
be9fc12 @tomlokhorst Moved stuff around
authored
42 fM :: JsC1 JsMaybe (Js JsBool) -> Js JsBool
43 --fM :: P.Maybe P.Bool -> P.Bool
44 fM = maybe false not
41c088e @tomlokhorst Clearified example.
authored
45
be9fc12 @tomlokhorst Moved stuff around
authored
46 test4 = fM (just true)
41c088e @tomlokhorst Clearified example.
authored
47
48
ed3dace @tomlokhorst Extended examples in Main
authored
49
50 listy :: [Int]
51 listy = 3 `cons` (4 `cons` nil)
f8df28b @tomlokhorst Working on Eq...
authored
52
be9fc12 @tomlokhorst Moved stuff around
authored
53 bool' :: a -> a -> P.Bool -> a
54 bool' x y b = if b then x else y
55
56 f :: (forall a. a -> a -> b -> a) -> a -> b -> a
57 f g a b = g a a b
58
59 ok = f bool'
60 -- epicfail = f bool
61
f8df28b @tomlokhorst Working on Eq...
authored
62 --
63 -- yo = either (P.* 5) (P.const 2)
64 -- (right false :: P.Either P.Int P.Bool)
65 -- -- (right false :: JsC2 JsEither (Js JsNumber) (Js JsBool))
66 --
67 -- ah = tuple2 (\x y -> x && P.const false y)
68 -- (ctuple2 true 3 :: (,) P.Bool P.Int)
69 -- -- (ctuple2 true 3 :: JsC2 JsTuple2 (Js JsBool) (Js JsNumber))
8b57a9e @tomlokhorst Initial checkin
authored
70
Something went wrong with that request. Please try again.