Skip to content

Instantly share code, notes, and snippets.

@vrom911
Created July 6, 2018 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrom911/6dbd65e8c47f89d468a4bd225b1b5a8d to your computer and use it in GitHub Desktop.
Save vrom911/6dbd65e8c47f89d468a4bd225b1b5a8d to your computer and use it in GitHub Desktop.
Core for lookup with binary search
-- RHS size: {terms: 9, types: 4, coercions: 0, joins: 0/0}
lookup1 :: Int# -> Any
lookup1
= \ (ipv :: Int#) ->
$wcheckError lvl24 245# Bounds lvl23 (checkIndex_msg# 0# ipv)
-- RHS size: {terms: 135, types: 101, coercions: 38, joins: 2/2}
$wlookup
:: forall k (a :: k) (f :: k -> *).
Typeable a =>
Int# -> Int# -> ByteArray# -> Vector Any -> Maybe (f a)
$wlookup
= \ (@ k)
(@ (a :: k))
(@ (f :: k -> *))
(w :: Typeable a)
(ww :: Int#)
(ww1 :: Int#)
(ww2 :: ByteArray#)
(ww3 :: Vector Any) ->
case typeRepFingerprint (w `cast` <Co:3>) of
{ Fingerprint dt dt1 ->
case <# 0# ww1 of {
__DEFAULT ->
case indexWord64Array# ww2 ww of wild2 { __DEFAULT ->
join {
exit :: Int# -> Maybe (f a)
exit (i :: Int#)
= Just
(case >=# i 0# of {
__DEFAULT ->
case ww3 of { Vector ipv ipv1 ipv2 ->
(lookup2 ipv1 i) `cast` <Co:7>
};
1# ->
case ww3 of { Vector ipv ipv1 ipv2 ->
case <# i ipv1 of {
__DEFAULT -> (lookup2 ipv1 i) `cast` <Co:7>;
1# ->
case indexArray# ipv2 (+# ipv i) of { (# ipv3 #) ->
ipv3 `cast` <Co:7>
}
}
}
}) } in
joinrec {
go :: Int# -> Maybe (f a)
go (i :: Int#)
= case <# i ww1 of {
__DEFAULT ->
case indexWord64Array# ww2 (+# ww i) of wild1 { __DEFAULT ->
case ltWord# dt wild1 of {
__DEFAULT -> jump go (+# (*# 2# i) 1#);
0# ->
case eqWord# dt wild1 of {
__DEFAULT -> jump exit i;
0# -> jump go (+# (*# 2# i) 2#)
}
}
};
0# -> Nothing
}; } in
case ltWord# dt wild2 of {
__DEFAULT -> jump go 1#;
0# ->
case eqWord# dt wild2 of {
__DEFAULT ->
Just
(case ww3 of { Vector ipv ipv1 ipv2 ->
case <# 0# ipv1 of {
__DEFAULT -> (lookup1 ipv1) `cast` <Co:7>;
1# ->
case indexArray# ipv2 ipv of { (# ipv3 #) -> ipv3 `cast` <Co:7> }
}
});
0# -> jump go 2#
}
}
};
0# -> Nothing
}
}
-- RHS size: {terms: 17, types: 30, coercions: 3, joins: 0/0}
lookup
:: forall k (a :: k) (f :: k -> *).
Typeable a =>
TypeRepMap f -> Maybe (f a)
lookup
= \ (@ k)
(@ (a :: k))
(@ (f :: k -> *))
(w :: Typeable a)
(w1 :: TypeRepMap f) ->
case w1 of { TypeRepMap ww1 ww2 ww3 ->
case ww1 `cast` <Co:3> of { Vector ww5 ww6 ww7 ->
$wlookup w ww5 ww6 ww7 ww3
}
}
-- RHS size: {terms: 9, types: 4, coercions: 0, joins: 0/0}
lookup1 :: Int# -> Any
lookup1
= \ (ipv :: Int#) ->
$wcheckError lvl24 245# Bounds lvl23 (checkIndex_msg# 0# ipv)
-- RHS size: {terms: 194, types: 119, coercions: 44, joins: 2/2}
$wlookup
:: forall k (a :: k) (f :: k -> *).
Typeable a =>
Int#
-> Int# -> ByteArray# -> Vector Word64 -> Vector Any -> Maybe (f a)
$wlookup
= \ (@ k)
(@ (a :: k))
(@ (f :: k -> *))
(w :: Typeable a)
(ww :: Int#)
(ww1 :: Int#)
(ww2 :: ByteArray#)
(ww3 :: Vector Word64)
(ww4 :: Vector Any) ->
case typeRepFingerprint (w `cast` <Co:3>) of
{ Fingerprint dt dt1 ->
case <# 0# ww1 of {
__DEFAULT ->
case indexWord64Array# ww2 ww of wild2 { __DEFAULT ->
join {
exit :: Int# -> Maybe (f a)
exit (i :: Int#)
= Just
(case >=# i 0# of {
__DEFAULT ->
case ww4 of { Vector ipv ipv1 ipv2 ->
(lookup2 ipv1 i) `cast` <Co:7>
};
1# ->
case ww4 of { Vector ipv ipv1 ipv2 ->
case <# i ipv1 of {
__DEFAULT -> (lookup2 ipv1 i) `cast` <Co:7>;
1# ->
case indexArray# ipv2 (+# ipv i) of { (# ipv3 #) ->
ipv3 `cast` <Co:7>
}
}
}
}) } in
joinrec {
go :: Int# -> Maybe (f a)
go (i :: Int#)
= case <# i ww1 of {
__DEFAULT ->
case indexWord64Array# ww2 (+# ww i) of wild1 { __DEFAULT ->
case ltWord# dt wild1 of {
__DEFAULT -> jump go (+# (*# 2# i) 1#);
0# ->
case eqWord# dt wild1 of {
__DEFAULT ->
case ww3 `cast` <Co:3> of { Vector dt2 dt3 dt4 ->
case indexWord64Array# dt4 (+# dt2 i) of wild4 { __DEFAULT ->
case eqWord# dt1 wild4 of {
__DEFAULT -> jump exit i;
0# ->
case ltWord# dt1 wild4 of {
__DEFAULT -> jump go (+# (*# 2# i) 1#);
0# -> jump go (+# (*# 2# i) 2#)
}
}
}
};
0# -> jump go (+# (*# 2# i) 2#)
}
}
};
0# -> Nothing
}; } in
case ltWord# dt wild2 of {
__DEFAULT -> jump go 1#;
0# ->
case eqWord# dt wild2 of {
__DEFAULT ->
case ww3 `cast` <Co:3> of { Vector dt2 dt3 dt4 ->
case indexWord64Array# dt4 dt2 of wild3 { __DEFAULT ->
case eqWord# dt1 wild3 of {
__DEFAULT ->
Just
(case ww4 of { Vector ipv ipv1 ipv2 ->
case <# 0# ipv1 of {
__DEFAULT -> (lookup1 ipv1) `cast` <Co:7>;
1# ->
case indexArray# ipv2 ipv of { (# ipv3 #) -> ipv3 `cast` <Co:7> }
}
});
0# ->
case ltWord# dt1 wild3 of {
__DEFAULT -> jump go 1#;
0# -> jump go 2#
}
}
}
};
0# -> jump go 2#
}
}
};
0# -> Nothing
}
}
-- RHS size: {terms: 18, types: 30, coercions: 3, joins: 0/0}
lookup
:: forall k (a :: k) (f :: k -> *).
Typeable a =>
TypeRepMap f -> Maybe (f a)
lookup
= \ (@ k)
(@ (a :: k))
(@ (f :: k -> *))
(w :: Typeable a)
(w1 :: TypeRepMap f) ->
case w1 of { TypeRepMap ww1 ww2 ww3 ->
case ww1 `cast` <Co:3> of { Vector ww5 ww6 ww7 ->
$wlookup w ww5 ww6 ww7 ww2 ww3
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment