diff options
Diffstat (limited to 'lc/Prelude.lc')
-rw-r--r-- | lc/Prelude.lc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lc/Prelude.lc b/lc/Prelude.lc index 698d4246..0c487352 100644 --- a/lc/Prelude.lc +++ b/lc/Prelude.lc | |||
@@ -127,12 +127,10 @@ instance Eq String where | |||
127 | ------------------------------------ Row polymorphism | 127 | ------------------------------------ Row polymorphism |
128 | -- todo: sorted field names (more efficient & easier to use) | 128 | -- todo: sorted field names (more efficient & easier to use) |
129 | 129 | ||
130 | {- | ||
130 | isKey _ [] = False | 131 | isKey _ [] = False |
131 | isKey s ((s', _): ss) = s === s' ||| isKey s ss | 132 | isKey s ((s', _): ss) = s === s' ||| isKey s ss |
132 | 133 | ||
133 | isKeyC _ _ [] = 'Empty "" | ||
134 | isKeyC s t ((s', t'): ss) = if s === s' then t ~ t' else isKeyC s t ss | ||
135 | |||
136 | subList [] _ = [] | 134 | subList [] _ = [] |
137 | subList ((s, t): xs) ys = if isKey s ys then subList xs ys else (s, t): subList xs ys | 135 | subList ((s, t): xs) ys = if isKey s ys then subList xs ys else (s, t): subList xs ys |
138 | 136 | ||
@@ -157,14 +155,17 @@ type instance Split z (RecordC xs) (RecordC ys) | defined xs &&& defined ys = T2 | |||
157 | -- TODO | 155 | -- TODO |
158 | record :: [(String, Type)] -> Type | 156 | record :: [(String, Type)] -> Type |
159 | --record xs = RecordCons ({- TODO: sortBy fst-} xs) | 157 | --record xs = RecordCons ({- TODO: sortBy fst-} xs) |
160 | 158 | -} | |
161 | -- builtin | 159 | -- builtin |
162 | unsafeCoerce :: forall a b . a -> b | 160 | unsafeCoerce :: forall a b . a -> b |
163 | 161 | ||
162 | isKeyC _ _ [] = 'Empty "" | ||
163 | isKeyC s t ((s', t'): ss) = if s === s' then t ~ t' else isKeyC s t ss | ||
164 | |||
164 | -- todo: don't use unsafeCoerce | 165 | -- todo: don't use unsafeCoerce |
165 | project :: forall a (xs :: [(String, Type)]) . forall (s :: String) -> 'isKeyC s a xs => RecordC xs -> a | 166 | project :: forall a (xs :: [(String, Type)]) . forall (s :: String) -> 'isKeyC s a xs => RecordC xs -> a |
166 | project @a @((s', a'): xs) s @_ (RecordCons ts) | s === s' = fst (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts) | 167 | project @a @((s', a'): xs) s @_ (RecordCons ts) | s === s' = fst (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts) |
167 | project @a @((s', a'): xs) s @_ (RecordCons ts) = project @a @xs s @undefined (RecordCons (snd (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts))) | 168 | project @a @((s', a'): xs) s @_ (RecordCons ts) = project @a @xs s @(undefined @(isKeyC s a xs)) (RecordCons (snd (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts))) |
168 | 169 | ||
169 | --------------------------------------- HTML colors | 170 | --------------------------------------- HTML colors |
170 | 171 | ||