This repository has been archived by the owner on Apr 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exper.glask
115 lines (89 loc) · 2.57 KB
/
exper.glask
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{ infixl 5 +
; infixl 5 *
; int'id :: Int -> Int
; int'id i = i
; maybe :: Maybe a -> a -> a
; maybe (Just x) _ = x
; maybe Nothing y = y
; class Num a where
{ (+) :: a -> a -> a
; (*) :: a -> a -> a }
; instance Num Int where
{ (+) x y = int#+ (x, y)
; (*) x y = int#* (x, y) }
; hmmm = 23 + 42
-- ; instance Num Double where
-- { (+) x y = double#+ (x, y)
-- ; (*) x y = double#* (x, y) }
; data Maybe a = Just a | Nothing
; data Bool = True | False
-- ; instance Num a => Num (Maybe a) where
-- { (+) (Just n) (Just m) = Just (n + m)
-- ; (*) (Just n) (Just m) = Just (n * m) }
; numberino :: a -> Int
; numberino _ = int#+ (23, 42)
; testing :: a -> Bool
; testing _ = True
; example :: Int
; example = 23 + 42
-- klic je to trignout u explicitnich funkci taky
-- tenhle example to presne trigne
-- ; fobar :: Num a => Maybe a -> a
-- ; fobar (Just n) = n + n
-- ; overloaded :: Num a => a -> a
-- ; overloaded a = a
--
-- ; foo n = let { r = overloaded n
-- ; m = int'id n }
-- in r
-- ; add'maybe :: Num a => a -> a
-- ; add'maybe :: Int -> Int
-- with, or without the annotation - it seems to be working fine
; add'maybe x = case Just x of
{ Just a -> a + a }
; a'fn :: Num a => a -> a
; a'fn x = x
-- this needs to propagate that constraint
-- and it does
; b'fn x = case a'fn x of
{ n -> n }
-- but this is somehow broken
; c'fn _ = case 23 of
{ n -> n }
-- weird experiments with monomorphism restriction
----
---- ; eee hole = let { x = 1 + 1 } in x
----
---- ; func hole = let { two = 1 + 1 }
---- in (two, \ x -> x + two) -- :: (forall a . Num a => (a, a -> a))
----
---- ; func' hole = let { two :: Num p => p
---- ; two = 1 + 1 }
---- in (two, \ x -> x + two) -- :: (forall a . Num a => (a, a -> a))
----
---- ; func1 hole = let { one = 1 } in (one, one)
----
---- -- ; baad' hole = let { fn :: a -> b -> a
---- -- ; fn x y = x }
---- -- in (fn, fn)
----
---- ; baad' hole = let { fn x y = x }
---- in (fn, fn)
----
---- ; baad1 hole = let { fn = \ x y -> x + y }
---- in (fn, fn)
-- I wanted to try this because in the infer'expl I have a question about this
-- ; zoar x y = raoz y (x + x)
-- ; raoz y x = zoar (char2num x) y
--
-- ; char2num :: Num a => Char -> a
-- ; char2num = char2num
-- stil works fine - it finds the error
-- ; class Woo a
--
-- -- ; broken :: a -> a -> a
-- ; broken :: Woo a => a -> a
-- ; broken a = a
--
-- ; woo x = broken True
}