summaryrefslogtreecommitdiff
path: root/lc/Prelude.lc
diff options
context:
space:
mode:
Diffstat (limited to 'lc/Prelude.lc')
-rw-r--r--lc/Prelude.lc11
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{-
130isKey _ [] = False 131isKey _ [] = False
131isKey s ((s', _): ss) = s === s' ||| isKey s ss 132isKey s ((s', _): ss) = s === s' ||| isKey s ss
132 133
133isKeyC _ _ [] = 'Empty ""
134isKeyC s t ((s', t'): ss) = if s === s' then t ~ t' else isKeyC s t ss
135
136subList [] _ = [] 134subList [] _ = []
137subList ((s, t): xs) ys = if isKey s ys then subList xs ys else (s, t): subList xs ys 135subList ((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
158record :: [(String, Type)] -> Type 156record :: [(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
162unsafeCoerce :: forall a b . a -> b 160unsafeCoerce :: forall a b . a -> b
163 161
162isKeyC _ _ [] = 'Empty ""
163isKeyC 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
165project :: forall a (xs :: [(String, Type)]) . forall (s :: String) -> 'isKeyC s a xs => RecordC xs -> a 166project :: forall a (xs :: [(String, Type)]) . forall (s :: String) -> 'isKeyC s a xs => RecordC xs -> a
166project @a @((s', a'): xs) s @_ (RecordCons ts) | s === s' = fst (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts) 167project @a @((s', a'): xs) s @_ (RecordCons ts) | s === s' = fst (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts)
167project @a @((s', a'): xs) s @_ (RecordCons ts) = project @a @xs s @undefined (RecordCons (snd (unsafeCoerce @_ @(a, tuptype (map snd xs)) ts))) 168project @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