Verified Commit f88446ea authored by Camil Staps's avatar Camil Staps 🚀

Remove ignored strictness annotations

parent 9fe0136c
......@@ -98,7 +98,7 @@ instance docDescription ParamDoc
* the arguments (the second argument). The first argument is the name.
*/
:: Property
= ForAll !String ![(!String,!Type)] !String
= ForAll !String ![(String,Type)] !String
/**
* When a property type contains type variables, a `PropertyVarInstantiation`
......@@ -251,7 +251,7 @@ parseDoc :: !String -> Either ParseError (!d, ![ParseWarning]) | docBlockToDoc{|
* @representation An order list of key-value pairs. A key can occur multiple
* times. The description has key `description`.
*/
:: DocBlock :== [(!String, !String)]
:: DocBlock :== [(String, String)]
/**
* The magic for {{`parseDoc`}}. Usually, a record type like {{`FunctionDoc`}}
......
......@@ -186,7 +186,7 @@ where
Left es -> Left (UnknownError "failed to parse property signature")
Right (name,args) -> Right (ForAll name args, [])
where
parser :: Parser Char (!String, ![(!String, !Type)])
parser :: Parser Char (!String, ![(String, Type)])
parser = skipSpaces *>
pMany (pSatisfy ((<>) ':')) >>= \name ->
skipSpaces *> pToken ':' *>
......
......@@ -109,7 +109,7 @@ where
:: UnificationState =
{ assignments :: ![TVAssignment]
, goals :: ![(!Type, !Type)]
, goals :: ![(Type, Type)]
, used_universal_vars :: ![TypeVar]
}
assignments s :== s.UnificationState.assignments
......
......@@ -6,7 +6,7 @@ from Data.Functor import class Functor
from Control.Applicative import class pure, class <*>, class Applicative
from Control.Monad import class Monad
mapArrSt :: !(.a -> .(*st -> *(!.a, !*st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
mapArrSt :: !(.a -> .(*st -> *(.a, *st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
foldrArr :: !(a .b -> .b) !.b !.(arr a) -> .b | Array arr a
......
......@@ -3,12 +3,12 @@ implementation module Data.Array
import StdArray, StdInt, StdOverloaded, StdClass, StdFunctions
import Data.Functor, Control.Applicative, Control.Monad
mapArrSt :: !(.a -> .(*st -> *(!.a, !*st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
mapArrSt :: !(.a -> .(*st -> *(.a, *st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
mapArrSt f arr st
#! (sz, arr) = usize arr
= mapArrSt` sz 0 f arr st
where
mapArrSt` :: !Int !Int !(.a -> .(*st -> *(!.a, !*st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
mapArrSt` :: !Int !Int !(.a -> .(*st -> *(.a, *st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
mapArrSt` sz idx f arr st
| idx == sz = (arr, st)
| otherwise
......
......@@ -5,4 +5,4 @@ from StdOverloaded import class ==
encodeInt :: ![Int] -> [Int]
decodeInt :: ![Int] -> [Int]
encode :: ![a] -> [(Int, a)] | == a
decode :: ![(!Int, !a)] -> [a] | == a
decode :: ![(Int, a)] -> [a] | == a
......@@ -27,17 +27,17 @@ decodeInt xs = reverse (rldInt` xs [])
encode :: ![a] -> [(Int, a)] | == a
encode xs = reverse (rle` xs [])
where
rle` :: ![a] ![(!Int, !a)] -> [(Int, a)] | == a
rle` :: ![a] ![(Int, a)] -> [(Int, a)] | == a
rle` [] acc = acc
rle` [x:xs] [] = rle` xs [(1, x)]
rle` [x:xs] [t=:(n, y) : ys]
| x == y = rle` xs [(n + 1, y) : ys]
| otherwise = rle` xs [(1, x) : t : ys]
decode :: ![(!Int, !a)] -> [a] | == a
decode :: ![(Int, a)] -> [a] | == a
decode xs = reverse (rld` xs [])
where
rld` :: ![(!Int, !a)] ![a] -> [a] | == a
rld` :: ![(Int, a)] ![a] -> [a] | == a
rld` [] acc = acc
rld` [(0, x) : xs] acc = rld` xs acc
rld` [(n, x) : xs] acc = rld` [(n - 1, x) : xs] [x : acc]
......
......@@ -102,7 +102,7 @@ combineErrors :: !(MaybeError e a) (MaybeError e b) (a b -> MaybeError e c) -> M
* @param The second operation, getting the result of the first as input
* @return The Error of the first or the second operation
*/
seqErrorsSt :: !(.st -> (MaybeError e a,!.st)) (a .st -> u:(!MaybeError e b, !.st)) !.st -> v:(MaybeError e b, !.st), [u <= v]
seqErrorsSt :: !(.st -> (MaybeError e a,.st)) (a .st -> u:(MaybeError e b, .st)) !.st -> v:(MaybeError e b, !.st), [u <= v]
/**
* Combines two MaybeError values, resulting from two operations on a state.
......@@ -113,4 +113,4 @@ seqErrorsSt :: !(.st -> (MaybeError e a,!.st)) (a .st -> u:(!MaybeError e b, !.s
* @param A combination function for the inputs if they are Ok
* @return The error of one of the operations or the result of the combination
*/
combineErrorsSt :: !(.st -> (!MaybeError e a, !.st)) (.st -> (!MaybeError e b, !.st)) (a b -> MaybeError e c) !.st -> (!MaybeError e c, !.st)
combineErrorsSt :: !(.st -> (MaybeError e a, .st)) (.st -> (MaybeError e b, .st)) (a b -> MaybeError e c) !.st -> (!MaybeError e c, !.st)
......@@ -68,7 +68,7 @@ combineErrors a b combf = case a of
Error e = Error e
Ok b = combf a b
seqErrorsSt :: !(.st -> (MaybeError e a,!.st)) (a .st -> u:(!MaybeError e b, !.st)) !.st -> v:(MaybeError e b, !.st), [u <= v]
seqErrorsSt :: !(.st -> (MaybeError e a,.st)) (a .st -> u:(MaybeError e b, .st)) !.st -> v:(MaybeError e b, !.st), [u <= v]
seqErrorsSt aop bop st
# (a,st) = aop st
= case a of
......@@ -76,7 +76,7 @@ seqErrorsSt aop bop st
Ok a = bop a st
combineErrorsSt :: !(.st -> (!MaybeError e a, !.st)) (.st -> (!MaybeError e b, !.st)) (a b -> MaybeError e c) !.st -> (!MaybeError e c, !.st)
combineErrorsSt :: !(.st -> (MaybeError e a, .st)) (.st -> (MaybeError e b, .st)) (a b -> MaybeError e c) !.st -> (!MaybeError e c, !.st)
combineErrorsSt aop bop combf st
# (a,st) = aop st
= case a of
......
......@@ -52,7 +52,7 @@ seqSt :: !(a .st -> .st) ![a] !.st -> .st
* @param The initial state.
* @result The value results and the final state.
*/
mapSt :: !(a .st -> (!b,!.st)) ![a] !.st -> (![b],.st)
mapSt :: !(a .st -> (b,.st)) ![a] !.st -> (![b],.st)
/**
* The fixed point combinator, reducing `fix f` to `f (fix f)`.
*/
......
......@@ -35,7 +35,7 @@ seqSt :: !(a .st -> .st) ![a] !.st -> .st
seqSt f [] st = st
seqSt f [x:xs] st = seqSt f xs (f x st)
mapSt :: !(a .st -> (!b,!.st)) ![a] !.st -> (![b],.st)
mapSt :: !(a .st -> (b,.st)) ![a] !.st -> (![b],.st)
mapSt f [] st = ([], st)
mapSt f [x:xs] st
# (y, st) = f x st
......
......@@ -62,7 +62,7 @@ setNodeData :: NodeIndex a u:(Graph a b) -> v:(Graph a b), [u <= v]
//Mapping
mapNodes :: !(a -> b) !.(Graph a e) -> .(Graph b e)
mapEdges :: !(a -> b) !.(Graph n a) -> .(Graph n b)
mapIndices :: ![(!NodeIndex,!NodeIndex)] !.(Graph n e) -> .(Graph n e)
mapIndices :: ![(NodeIndex,NodeIndex)] !.(Graph n e) -> .(Graph n e)
//Folding
foldrNodes :: (NodeIndex (Node n) .a -> .a) .a .(Graph n e) -> .a
......
......@@ -224,7 +224,7 @@ where
mapMap :: (a -> b) (Map k a) -> (Map k b) | Eq k & Ord k
mapMap f m = (fromList o map (app2 (id,f)) o toList) m
mapIndices :: ![(!NodeIndex,!NodeIndex)] !.(Graph n e) -> .(Graph n e)
mapIndices :: ![(NodeIndex,NodeIndex)] !.(Graph n e) -> .(Graph n e)
mapIndices updates { nodes, edges }
# updMap = fromList updates
= { Graph
......
......@@ -50,7 +50,7 @@ foldrWithKey :: (Int a b -> b) b !(IntMap a) -> b
* where
* distinctAscList = sort $ removeDup list
*/
fromDistinctAscList :: ![(!Int, !a)] -> IntMap a
fromDistinctAscList :: ![(Int, a)] -> IntMap a
union :: !(IntMap a) !(IntMap a) -> IntMap a
......
......@@ -1488,15 +1488,15 @@ fromAscListWithKey f [x0 : xs0] = fromDistinctAscList (combineEq x0 xs0)
// /The precondition (input list is strictly ascending) is not checked./
//
// > fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
fromDistinctAscList :: ![(!Int, !a)] -> IntMap a
fromDistinctAscList :: ![(Int, a)] -> IntMap a
fromDistinctAscList [] = Nil
fromDistinctAscList [z0 : zs0] = work z0 zs0 Nada
where
work :: !(!Int, !a) ![(!Int, !a)] !(Stack a) -> IntMap a
work :: !(!Int, !a) ![(Int, a)] !(Stack a) -> IntMap a
work (kx,vx) [] stk = finish kx (Tip kx vx) stk
work (kx,vx) [z=:(kz,_):zs] stk = reduce z zs (branchMask kx kz) kx (Tip kx vx) stk
reduce :: !(!Int, !a) ![(!Int, !a)] !Mask !Prefix !(IntMap a) !(Stack a) -> IntMap a
reduce :: !(!Int, !a) ![(Int, a)] !Mask !Prefix !(IntMap a) !(Stack a) -> IntMap a
reduce z zs _ px tx Nada = work z zs (Push px tx Nada)
reduce z zs m px tx stk=:(Push py ty stk`) =
let mxy = branchMask px py
......
......@@ -149,7 +149,7 @@ map :: !(a -> b) !(IntMap a) -> IntMap b
// > mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
mapWithKey :: !(Int a -> b) !(IntMap a) -> IntMap b
mapSt :: !(a *st -> *(!b, !*st)) !.(IntMap a) !*st -> *(!IntMap b, !*st)
mapSt :: !(a *st -> *(b, *st)) !.(IntMap a) !*st -> *(!IntMap b, !*st)
/**
* @property is distinct and sorted: A.list :: [(Int, a)]:
......@@ -157,14 +157,14 @@ mapSt :: !(a *st -> *(!b, !*st)) !.(IntMap a) !*st -> *(!IntMap b, !*st)
* where
* distinctAscList = sort $ removeDup list
*/
toList :: !(IntMap a) -> [(!Int, !a)]
toList :: !(IntMap a) -> [(Int, a)]
toAscList :: !(IntMap a) -> [(!Int, !a)]
toAscList :: !(IntMap a) -> [(Int, a)]
fromList :: ![(!Int, !a)] -> IntMap a
fromList :: ![(Int, a)] -> IntMap a
// | /O(n*min(n,W))/. Create a map from a list of key\/value pairs with a combining function. See also 'fromAscListWith'.
//
// > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
// > fromListWith (++) [] == empty
fromListWith :: !(a a -> a) ![(!Int, !a)] -> IntMap a
fromListWith :: !(a a -> a) ![(Int, a)] -> IntMap a
......@@ -513,7 +513,7 @@ mapWithKey f t
//
// > let f a b = (a ++ b, b ++ "X")
// > mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])
mapAccum :: !(a b -> (!a, !c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccum :: !(a b -> (a, c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccum f v m = mapAccumWithKey (\a` _ x -> f a` x) v m
// | /O(n)/. The function @'mapAccumWithKey'@ threads an accumulating
......@@ -521,14 +521,14 @@ mapAccum f v m = mapAccumWithKey (\a` _ x -> f a` x) v m
//
// > let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X")
// > mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")])
mapAccumWithKey :: !(a Int b -> (!a, !c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccumWithKey :: !(a Int b -> (a, c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccumWithKey f a t = mapAccumL f a t
// | /O(n)/. The function @'mapAccumL'@ threads an accumulating
// argument through the map in ascending order of keys. Strict in
// the accumulating argument and the both elements of the
// result of the function.
mapAccumL :: !(a Int b -> (!a, !c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccumL :: !(a Int b -> (a, c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccumL f a t
= case t of
Bin p m l r
......@@ -542,7 +542,7 @@ mapAccumL f a t
// | /O(n)/. The function @'mapAccumR'@ threads an accumulating
// argument through the map in descending order of keys.
mapAccumRWithKey :: !(a Int b -> (!a, !c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccumRWithKey :: !(a Int b -> (a, c)) !a !(IntMap b) -> (!a, !IntMap c)
mapAccumRWithKey f a t
= case t of
Bin p m l r
......@@ -645,7 +645,7 @@ mapEitherWithKey _ Nil = (Nil, Nil)
// > fromList [] == empty
// > fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
// > fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
fromList :: ![(!Int, !a)] -> IntMap a
fromList :: ![(Int, a)] -> IntMap a
fromList xs
= foldlStrict ins empty xs
where
......@@ -655,14 +655,14 @@ fromList xs
//
// > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
// > fromListWith (++) [] == empty
fromListWith :: !(a a -> a) ![(!Int, !a)] -> IntMap a
fromListWith :: !(a a -> a) ![(Int, a)] -> IntMap a
fromListWith f xs = fromListWithKey (\_ x y -> f x y) xs
// | /O(n*min(n,W))/. Build a map from a list of key\/value pairs with a combining function. See also fromAscListWithKey'.
//
// > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
// > fromListWith (++) [] == empty
fromListWithKey :: !(Int a a -> a) ![(!Int, !a)] -> IntMap a
fromListWithKey :: !(Int a a -> a) ![(Int, a)] -> IntMap a
fromListWithKey f xs = foldlStrict ins empty xs
where
ins t (k,x) = insertWithKey f k x t
......@@ -672,7 +672,7 @@ fromListWithKey f xs = foldlStrict ins empty xs
//
// > fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
// > fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]
fromAscList :: ![(!Int, a)] -> IntMap a
fromAscList :: ![(Int, a)] -> IntMap a
fromAscList xs = fromAscListWithKey (\_ x _ -> x) xs
// | /O(n)/. Build a map from a list of key\/value pairs where
......@@ -680,7 +680,7 @@ fromAscList xs = fromAscListWithKey (\_ x _ -> x) xs
// /The precondition (input list is ascending) is not checked./
//
// > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
fromAscListWith :: !(a a -> a) ![(!Int, !a)] -> IntMap a
fromAscListWith :: !(a a -> a) ![(Int, a)] -> IntMap a
fromAscListWith f xs = fromAscListWithKey (\_ x y -> f x y) xs
// | /O(n)/. Build a map from a list of key\/value pairs where
......@@ -688,7 +688,7 @@ fromAscListWith f xs = fromAscListWithKey (\_ x y -> f x y) xs
// /The precondition (input list is ascending) is not checked./
//
// > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
fromAscListWithKey :: !(Int a a -> a) ![(!Int, !a)] -> IntMap a
fromAscListWithKey :: !(Int a a -> a) ![(Int, a)] -> IntMap a
fromAscListWithKey _ [] = Nil
fromAscListWithKey f [x0 : xs0] = fromDistinctAscList (combineEq x0 xs0)
where
......@@ -705,14 +705,14 @@ fromAscListWithKey f [x0 : xs0] = fromDistinctAscList (combineEq x0 xs0)
// /The precondition (input list is strictly ascending) is not checked./
//
// > fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
//fromDistinctAscList :: ![(!Int, !a)] -> IntMap a
//fromDistinctAscList :: ![(Int, a)] -> IntMap a
//fromDistinctAscList [] = Nil
//fromDistinctAscList [z0 : zs0] = work z0 zs0 Nada
//where
//work (kx,vx) [] stk = finish kx (Tip kx vx) stk
//work (kx,vx) [z=:(kz,_):zs] stk = reduce z zs (branchMask kx kz) kx (Tip kx vx) stk
//reduce :: !(!Int, !a) ![(!Int, !a)] !Mask !Prefix !(IntMap a) !(Stack a) -> IntMap a
//reduce :: !(!Int, !a) ![(Int, a)] !Mask !Prefix !(IntMap a) !(Stack a) -> IntMap a
//reduce z zs _ px tx Nada = work z zs (Push px tx Nada)
//reduce z zs m px tx stk=:(Push py ty stk`) =
//let mxy = branchMask px py
......@@ -733,7 +733,7 @@ instance Functor IntMap where
fmap f (Tip n x) = Tip n (f x)
fmap f (Bin p m l r) = Bin p m (fmap f l) (fmap f r)
mapSt :: !(a *st -> *(!b, !*st)) !.(IntMap a) !*st -> *(!IntMap b, !*st)
mapSt :: !(a *st -> *(b, *st)) !.(IntMap a) !*st -> *(!IntMap b, !*st)
mapSt _ Nil st = (Nil, st)
mapSt f (Tip n x) st
#! (x, st) = f x st
......@@ -829,12 +829,12 @@ maybe_link p1 t1 p2 t2 = link p1 t1 p2 t2
//
// > toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
// > toList empty == []
toList :: !(IntMap a) -> [(!Int, !a)]
toList :: !(IntMap a) -> [(Int, a)]
toList m = toAscList m
// | /O(n)/. Convert the map to a list of key\/value pairs where the
// keys are in ascending order. Subject to list fusion.
//
// > toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
toAscList :: !(IntMap a) -> [(!Int, !a)]
toAscList :: !(IntMap a) -> [(Int, a)]
toAscList m = foldrWithKey (\k x xs -> [(k,x):xs]) [] m
......@@ -79,7 +79,7 @@ unzip5 :: ![(.a,.b,.c,.d,.e)] -> ([.a],[.b],[.c],[.d],[.e])
* @result The original list, with all elements x for which p r x holds replaced by r
*/
replaceInList :: !(a a -> Bool) !a ![a] -> [a]
sortByIndex :: ![(!Int,!a)] -> [a]
sortByIndex :: ![(Int,a)] -> [a]
intersperse :: !a ![a] -> [a]
intercalate :: !.[a] ![.[a]] -> .[a]
transpose :: ![[a]] -> [.[a]]
......@@ -148,17 +148,17 @@ strictTRMapAcc :: !(u:a -> v:b) !w:[u:a] !x:[v:b] -> y:[v:b], [w <= u,y <=
strictTRMap :: !(.a -> .b) ![.a] -> [.b]
reverseTR :: ![.a] -> [.a]
flattenTR :: ![[a]] -> [a]
strictTRMapSt :: !(a .st -> (!b, !.st)) ![a] !.st -> (![b], !.st)
strictTRMapStAcc :: !(a .st -> (!b, !.st)) ![a] ![b] !.st -> (![b], !.st)
strictTRMapSt :: !(a .st -> (b, .st)) ![a] !.st -> (![b], !.st)
strictTRMapStAcc :: !(a .st -> (b, .st)) ![a] ![b] !.st -> (![b], !.st)
strictTRZipWith :: !(a b -> c) ![a] ![b] -> [c]
strictTRZipWithRev :: !(a b -> c) ![a] ![b] -> [c]
strictTRZipWithAcc :: !(a b -> c) ![a] ![b] ![c] -> [c]
strictTRZip4 :: ![a] ![b] ![c] ![d] -> [(!a, !b, !c, !d)]
strictTRZip4Rev :: ![a] ![b] ![c] ![d] -> [(!a, !b, !c, !d)]
strictTRZip4Acc :: ![a] ![b] ![c] ![d] ![(!a, !b, !c, !d)] -> [(!a, !b, !c, !d)]
strictTRZip2 :: ![a] ![b]-> [(!a, !b)]
strictTRZip2Rev :: ![a] ![b]-> [(!a, !b)]
strictTRZip2Acc :: ![a] ![b] ![(!a, !b)] -> [(!a, !b)]
strictTRZip4 :: ![a] ![b] ![c] ![d] -> [(a, b, c, d)]
strictTRZip4Rev :: ![a] ![b] ![c] ![d] -> [(a, b, c, d)]
strictTRZip4Acc :: ![a] ![b] ![c] ![d] ![(a, b, c, d)] -> [(a, b, c, d)]
strictTRZip2 :: ![a] ![b]-> [(a, b)]
strictTRZip2Rev :: ![a] ![b]-> [(a, b)]
strictTRZip2Acc :: ![a] ![b] ![(a, b)] -> [(a, b)]
strictTRZipWith3 :: !(a b c -> d) ![a] ![b] ![c] -> [d]
strictTRZipWith3Rev :: !(a b c -> d) ![a] ![b] ![c] -> [d]
strictTRZipWith3Acc :: !(a b c -> d) ![a] ![b] ![c] ![d] -> [d]
......
......@@ -117,7 +117,7 @@ replaceInList cond new [x:xs]
| cond new x = [new : xs]
| otherwise = [x : replaceInList cond new xs]
sortByIndex :: ![(!Int,!a)] -> [a]
sortByIndex :: ![(Int,a)] -> [a]
sortByIndex l = map snd (sortBy (\(a,_) (b,_) -> a < b) l)
intersperse :: !a ![a] -> [a]
......@@ -403,12 +403,12 @@ flattenTRAcc [xs:xss] acc
#! r = reverseTR xs ++ acc
= flattenTRAcc xss r
strictTRMapSt :: !(a .st -> (!b, !.st)) ![a] !.st -> (![b], !.st)
strictTRMapSt :: !(a .st -> (b, .st)) ![a] !.st -> (![b], !.st)
strictTRMapSt f xs st
#! (rs, st) = strictTRMapStAcc f xs [] st
= (reverseTR rs, st)
strictTRMapStAcc :: !(a .st -> (!b, !.st)) ![a] ![b] !.st -> (![b], !.st)
strictTRMapStAcc :: !(a .st -> (b, .st)) ![a] ![b] !.st -> (![b], !.st)
strictTRMapStAcc f [] acc st = (acc, st)
strictTRMapStAcc f [x:xs] acc st
#! (r, st) = f x st
......@@ -425,24 +425,24 @@ strictTRZipWithAcc f [a:as] [b:bs] acc
= strictTRZipWithAcc f as bs [f a b : acc]
strictTRZipWithAcc _ _ _ acc = acc
strictTRZip4 :: ![a] ![b] ![c] ![d] -> [(!a, !b, !c, !d)]
strictTRZip4 :: ![a] ![b] ![c] ![d] -> [(a, b, c, d)]
strictTRZip4 as bs cs ds = reverseTR (strictTRZip4Rev as bs cs ds)
strictTRZip4Rev :: ![a] ![b] ![c] ![d] -> [(!a, !b, !c, !d)]
strictTRZip4Rev :: ![a] ![b] ![c] ![d] -> [(a, b, c, d)]
strictTRZip4Rev as bs cs ds = strictTRZip4Acc as bs cs ds []
strictTRZip4Acc :: ![a] ![b] ![c] ![d] ![(!a, !b, !c, !d)] -> [(!a, !b, !c, !d)]
strictTRZip4Acc :: ![a] ![b] ![c] ![d] ![(a, b, c, d)] -> [(a, b, c, d)]
strictTRZip4Acc [a:as] [b:bs] [c:cs] [d:ds] acc
= strictTRZip4Acc as bs cs ds [(a, b, c, d):acc]
strictTRZip4Acc _ _ _ _ acc = acc
strictTRZip2 :: ![a] ![b]-> [(!a, !b)]
strictTRZip2 :: ![a] ![b]-> [(a, b)]
strictTRZip2 as bs = reverseTR (strictTRZip2Rev as bs)
strictTRZip2Rev :: ![a] ![b]-> [(!a, !b)]
strictTRZip2Rev :: ![a] ![b]-> [(a, b)]
strictTRZip2Rev as bs = strictTRZip2Acc as bs []
strictTRZip2Acc :: ![a] ![b] ![(!a, !b)] -> [(!a, !b)]
strictTRZip2Acc :: ![a] ![b] ![(a, b)] -> [(a, b)]
strictTRZip2Acc [a:as] [b:bs] acc
= strictTRZip2Acc as bs [(a, b):acc]
strictTRZip2Acc _ _ acc = acc
......
......@@ -276,7 +276,7 @@ toAscList m :== foldrWithKey (\k x xs -> [(k,x):xs]) [] m
* m = fromList elems
* @complexity O(n*log n)
*/
fromList :: !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v]
fromList :: !u:[v:(a, b)] -> Map a b | == a & < a, [u <= v]
/**
* The keys of all keys of a map.
......
......@@ -972,7 +972,7 @@ traverseWithKey f (Bin s k v l r) = flip (Bin s k) <$> traverseWithKey f l <*> f
// > let f a b = (a ++ b, b ++ "X")
// > mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])
mapAccum :: !(a b -> (!a, !c)) !a !(Map k b) -> (!a, !Map k c)
mapAccum :: !(a b -> (a, c)) !a !(Map k b) -> (!a, !Map k c)
mapAccum f a m = mapAccumWithKey (\a` _ x` -> f a` x`) a m
// | /O(n)/. The function 'mapAccumWithKey` threads an accumulating
......@@ -981,12 +981,12 @@ mapAccum f a m = mapAccumWithKey (\a` _ x` -> f a` x`) a m
// > let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X")
// > mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")])
mapAccumWithKey :: !(a k b -> (!a, !c)) !a !(Map k b) -> (!a, !Map k c)
mapAccumWithKey :: !(a k b -> (a, c)) !a !(Map k b) -> (!a, !Map k c)
mapAccumWithKey f a t = mapAccumL f a t
// | /O(n)/. The function 'mapAccumL' threads an accumulating
// argument through the map in ascending order of keys.
mapAccumL :: !(a k b -> (!a, !c)) !a !(Map k b) -> (!a, !Map k c)
mapAccumL :: !(a k b -> (a, c)) !a !(Map k b) -> (!a, !Map k c)
mapAccumL _ a Tip = (a,Tip)
mapAccumL f a (Bin sx kx x l r)
#! (a1,l`) = mapAccumL f a l
......@@ -996,7 +996,7 @@ mapAccumL f a (Bin sx kx x l r)
// | /O(n)/. The function 'mapAccumR' threads an accumulating
// argument through the map in descending order of keys.
mapAccumRWithKey :: !(a k b -> (!a, !c)) !a !(Map k b) -> (!a, !Map k c)
mapAccumRWithKey :: !(a k b -> (a, c)) !a !(Map k b) -> (!a, !Map k c)
mapAccumRWithKey _ a Tip = (a,Tip)
mapAccumRWithKey f a (Bin sx kx x l r)
#! (a1,r`) = mapAccumRWithKey f a r
......@@ -1177,7 +1177,7 @@ foldMapWithKey f (Bin _ k v l r) = mappend (foldMapWithKey f l) (mappend (f k v)
// > assocs (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
// > assocs newMap == []
assocs :: !(Map k a) -> [(!k, !a)]
assocs :: !(Map k a) -> [(k, a)]
assocs m = toAscList m
keysSet :: !(Map k a) -> Set k
......@@ -1188,22 +1188,22 @@ fromSet :: !(k -> a) !(Set k) -> Map k a
fromSet _ 'Data.Set'.Tip = Tip
fromSet f ('Data.Set'.Bin sz x l r) = Bin sz x (f x) (fromSet f l) (fromSet f r)
fromList :: !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v]
fromList :: !u:[v:(a, b)] -> Map a b | == a & < a, [u <= v]
fromList [] = Tip
fromList [(kx, x)] = Bin 1 kx x Tip Tip
fromList [(kx0, x0) : xs0]
| not_ordered kx0 xs0 = fromList` (Bin 1 kx0 x0 Tip Tip) xs0
| otherwise = go 1 (Bin 1 kx0 x0 Tip Tip) xs0
where
not_ordered :: !a !u:[v:(!a, !b)] -> Bool | == a & < a, [u <= v]
not_ordered :: !a !u:[v:(a, b)] -> Bool | == a & < a, [u <= v]
not_ordered _ [] = False
not_ordered kx [(ky,_) : _] = kx >= ky
fromList` :: !(Map a b) !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v]
fromList` :: !(Map a b) !u:[v:(a, b)] -> Map a b | == a & < a, [u <= v]
fromList` t0 xs = foldl ins t0 xs
where ins t (k,x) = put k x t
go :: !Int !(Map a b) !u:[v:(!a, !b)] -> Map a b | == a & < a, [u <= v]
go :: !Int !(Map a b) !u:[v:(a, b)] -> Map a b | == a & < a, [u <= v]
go _ t [] = t
go _ t [(kx, x)] = putMax kx x t
go s l xs=:[(kx, x) : xss]
......@@ -1217,7 +1217,7 @@ fromList [(kx0, x0) : xs0]
// If ys is nonnewMap, the keys in ys are not ordered with respect to tree
// and must be puted using fromList`. Otherwise the keys have been
// ordered so far.
create :: !Int !u:[v:(!a, !b)] -> (!Map a b, ![(!a, !b)], ![(!a, !b)]) | == a & < a, [u <= v]
create :: !Int !u:[v:(a, b)] -> (!Map a b, ![(a, b)], ![(a, b)]) | == a & < a, [u <= v]
create _ [] = (Tip, [], [])
create s xs=:[xp : xss]
| s == 1 = case xp of (kx, x) | not_ordered kx xss -> (Bin 1 kx x Tip Tip, [], xss)
......@@ -1234,7 +1234,7 @@ fromList [(kx0, x0) : xs0]
// > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
// > fromListWith (++) [] == newMap
//fromListWith :: !(a a -> a) ![(!k, !a)] -> Map k a | < k
//fromListWith :: !(a a -> a) ![(k, a)] -> Map k a | < k
fromListWith f xs :== fromListWithKey (\_ x y -> f x y) xs
// | /O(n*log n)/. Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWithKey`.
......@@ -1243,7 +1243,7 @@ fromListWith f xs :== fromListWithKey (\_ x y -> f x y) xs
// > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]
// > fromListWithKey f [] == newMap
fromListWithKey :: !(k a a -> a) ![(!k, !a)] -> Map k a | < k
fromListWithKey :: !(k a a -> a) ![(k, a)] -> Map k a | < k
fromListWithKey f xs = foldl (ins f) newMap xs
where
ins :: !(k a a -> a) !(Map k a) !(!k, !a) -> Map k a | < k
......@@ -1254,7 +1254,7 @@ fromListWithKey f xs = foldl (ins f) newMap xs
// > toList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
// > toList newMap == []
//toList :: !(Map k a) -> [(!k, !a)]
//toList :: !(Map k a) -> [(k, a)]
//toList m = toAscList m
// | /O(n)/. Convert the map to a list of key\/value pairs where the keys are
......@@ -1262,14 +1262,14 @@ fromListWithKey f xs = foldl (ins f) newMap xs
//
// > toAscList (fromList [(5,"a"), (3,"b")]) == [(3,"b"), (5,"a")]
//toAscList :: !(Map k a) -> [(!k, !a)]
//toAscList :: !(Map k a) -> [(k, a)]
// | /O(n)/. Convert the map to a list of key\/value pairs where the keys
// are in descending order. Subject to list fusion.
//
// > toDescList (fromList [(5,"a"), (3,"b")]) == [(5,"a"), (3,"b")]
toDescList :: !(Map k a) -> [(!k, !a)]
toDescList :: !(Map k a) -> [(k, a)]
toDescList m = foldlWithKey (\xs k x -> [(k,x):xs]) [] m
//////////////////////////////////////////////////////////////////////
......@@ -1287,7 +1287,7 @@ toDescList m = foldlWithKey (\xs k x -> [(k,x):xs]) [] m
// > valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True
// > valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == False
fromAscList :: ![(!k, !a)] -> Map k a | == k
fromAscList :: ![(k, a)] -> Map k a | == k
fromAscList xs = fromAscListWithKey (\_ x _ -> x) xs
// | /O(n)/. Build a map from an ascending list in linear time with a combining function for equal keys.
......@@ -1297,7 +1297,7 @@ fromAscList xs = fromAscListWithKey (\_ x _ -> x) xs
// > valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True
// > valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
fromAscListWith :: !(a a -> a) ![(!k, !a)] -> Map k a | == k
fromAscListWith :: !(a a -> a) ![(k, a)] -> Map k a | == k
fromAscListWith f xs = fromAscListWithKey (\_ x y -> f x y) xs
// | /O(n)/. Build a map from an ascending list in linear time with a
......@@ -1309,18 +1309,18 @@ fromAscListWith f xs = fromAscListWithKey (\_ x y -> f x y) xs
// > valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True
// > valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
fromAscListWithKey :: !(k a a -> a) ![(!k, !a)] -> Map k a | == k
fromAscListWithKey :: !(k a a -> a) ![(k, a)] -> Map k a | == k
fromAscListWithKey f xs = fromDistinctAscList (combineEq f xs)
where
// [combineEq f xs] combines equal elements with function [f] in an ordered list [xs]
combineEq :: !(k a a -> a) ![(!k, !a)] -> [(!k, !a)] | == k
combineEq :: !(k a a -> a) ![(k, a)] -> [(k, a)] | == k
combineEq f xs`
= case xs` of
[] -> []
[x] -> [x]
[x:xx] -> combineEq` f x xx
combineEq` :: !(k a a -> a) !(!k, !a) ![(!k, !a)] -> [(!k, !a)] | == k
combineEq` :: !(k a a -> a) !(!k, !a) ![(k, a)] -> [(k, a)] | == k
combineEq` _ z [] = [z]
combineEq` f z=:(kz,zz) [x=:(kx,xx):xs`]
| kx == kz
......@@ -1337,16 +1337,16 @@ fromAscListWithKey f xs = fromDistinctAscList (combineEq f xs)
// For some reason, when 'singleton' is used in fromDistinctAscList or in
// create, it is not inlined, so we inline it manually.
fromDistinctAscList :: ![(!k, !a)] -> Map k a
fromDistinctAscList :: ![(k, a)] -> Map k a
fromDistinctAscList [] = Tip
fromDistinctAscList [(kx0, x0) : xs0] = go 1 (Bin 1 kx0 x0 Tip Tip) xs0
where
go :: !Int !(Map a b) ![(!a, !b)] -> Map a b
go :: !Int !(Map a b) ![(a, b)] -> Map a b
go _ t [] = t
go s l [(kx, x) : xs] = case create s xs of
(r, ys) -> go (s << 1) (link kx x l r) ys
create :: !Int ![(!a, !b)] -> (!Map a b, ![(!a, !b)])
create :: !Int ![(a, b)] -> (!Map a b, ![(a, b)])
create _ [] = (Tip, [])
create s xs=:[x` : xs`]
| s == 1 = case x` of (kx, x) -> (Bin 1 kx x Tip Tip, xs`)
......
definition module Data.Tuple
from Control.Monad import class pure, class <*>, class Applicative
from Control.Monad import class pure, class <*>, class Applicative, class Monad
from Data.Functor import class Functor
from Data.Monoid import class Semigroup, class Monoid
from Data.Foldable import class Foldable
......
......@@ -103,7 +103,7 @@ unsearchIndex :: !Index !*(NativeDB v a) -> *NativeDB v a
/**
* Like {{`search`}}, but search for specific indices.
*/
searchIndices :: !SearchMode ![(!Index, ![!a!])] !*(NativeDB v a) -> *NativeDB v a
searchIndices :: !SearchMode ![(Index, [!a!])] !*(NativeDB v a) -> *NativeDB v a
/**
* Exclude a list of indices.
......@@ -119,12 +119,12 @@ unsearchIndices` :: !{#Index} !*(NativeDB v a) -> *NativeDB v a
* Like {{`searchIndices`}}, but also check on some property.
* This search always uses the {{`AddExcluded`}} {{`SearchMode`}}.
*/
searchWithIndices :: !(v -> (Bool, ![!a!])) ![Index] !*(NativeDB v a) -> *NativeDB v a
searchWithIndices :: !(v -> (Bool, [!a!])) ![Index] !*(NativeDB v a) -> *NativeDB v a
/**
* Like {{`searchWithIndices`}}, but with an array of indices.
*/
searchWithIndices` :: !(v -> (Bool, ![!a!])) !{#Index} !*(NativeDB v a) -> *NativeDB v a
searchWithIndices` :: !(v -> (Bool, [!a!])) !{#Index} !*(NativeDB v a) -> *NativeDB v a
/**
* Retrieve an entry.
......
......@@ -154,7 +154,7 @@ searchIndex (Index i) new_annots db
unsearchIndex :: !Index !*(NativeDB v a) -> *NativeDB v a
unsearchIndex (Index i) db = {db & [i].included=False}
searchIndices :: !SearchMode ![(!Index, ![!a!])] !*(NativeDB v a) -> *NativeDB v a
searchIndices :: !SearchMode ![(Index, [!a!])] !*(NativeDB v a) -> *NativeDB v a
searchIndices mode idxs db = case mode of
Intersect
# (s,db) = usize db
......@@ -167,7 +167,7 @@ where
# (annots,es) = es![i].annotations
= {es & [i].included=True, [i].annotations=new_annots ++$ annots}
upd_intersect :: !Int !Int ![(!Index, ![!a!])] !*{!*Entry v a} -> *{!*Entry v a}
upd_intersect :: !Int !Int ![(Index, [!a!])] !*{!*Entry v a} -> *{!*Entry v a}
upd_intersect i s _ es | i > s = es
upd_intersect i s [] es = upd_intersect (i+1) s [] {es & [i].included=False}
upd_intersect i s allidxs=:[(Index idx,new_annots):idxs] es
......@@ -195,10 +195,10 @@ where
# (Index ei) = idxs.[i]
= upd (i-1) idxs {es & [ei].included=False}
searchWithIndices :: !(v -> (Bool, ![!a!])) ![Index] !*(NativeDB v a) -> *NativeDB v a
searchWithIndices :: !(v -> (Bool, [!a!])) ![Index] !*(NativeDB v a) -> *NativeDB v a
searchWithIndices prop idxs db = upd prop idxs db
where
upd :: !(v -> (Bool, ![!a!])) ![Index] !*{!*Entry v a} -> *{!*Entry v a}
upd :: !(v -> (Bool, [!a!])) ![Index] !*{!*Entry v a} -> *{!*Entry v a}
upd _ [] es = es
upd prop [Index i:is] es
# (val,es) = es![i].value
......@@ -209,12 +209,12 @@ where
# (annots,es) = es![i].annotations
-> upd prop is {es & [i].included=True, [i].annotations=new_annots ++$ annots}
searchWithIndices` :: !(v -> (Bool, ![!a!])) !{#Index} !*(NativeDB v a) -> *NativeDB v a
searchWithIndices` :: !(v -> (Bool, [!a!])) !{#Index} !*(NativeDB v a) -> *NativeDB v a
searchWithIndices` prop idxs db
# (sz,idxs) = usize idxs
= upd prop (sz-1) idxs db
where
upd :: !(v -> (Bool, ![!a!])) !Int !{#Index} !*{!*Entry v a} -> *{!*Entry v a}
upd :: !(v -> (Bool, [!a!])) !Int !{#Index} !*{!*Entry v a} -> *{!*Entry v a}
upd _ -1 _ es = es
upd prop i idxs es
# (Index ei) = idxs.[i]
......
......@@ -9,7 +9,7 @@ from System.Time import :: Clock, :: Timespec
* @param computation on the unique environment
* @return function that additionally measures the duration of the given computation (second result integer is wall time)
*/
measureTime :: !u:(*env -> *env) -> v:(*env -> (!Int, !Int, !*env)), [v <= u]
measureTime :: !u:(*env -> *env) -> v:(*env -> (Int, Int, *env)), [v <= u]
/**
* Measures the duration of the computation on a unique environment, returning an additional result.
......@@ -18,7 +18,7 @@ measureTime :: !u:(*env -> *env) -> v:(*env -> (!Int, !Int, !*env)), [v <= u]
* @param computation on the unique environment
* @return function that additionally measures the duration of the given computation (second result integer is wall time)
*/
measureTimeRes :: !u:(*env -> (!.a, !*env)) -> v:(*env -> (!Int, !Int, !.a, !*env)), [v <= u]
measureTimeRes :: !u:(*env -> (.a, *env)) -> v:(*env -> (Int, Int, .a, *env)), [v <= u]
/**
* Prints the duration of the computation on a unique environment.
......@@ -38,4 +38,4 @@ printTime :: !String !u:(*env -> *env) -> v:(*env -> *env), [v <= u]
* @param computation on the unique environment
* @return function that additionally prints the duration of the given computation
*/
printTimeRes :: !String !u:(*env -> (!.a, !*env)) -> v:(*env -> (!.a, !*env)), [v <= u]
printTimeRes :: !String !u:(*env -> (.a, *env)) -> v:(*env -> (.a, *env)), [v <= u]
......@@ -6,7 +6,7 @@ from StdFunc import seq, o
// stores the indentation level in global environment variable
NIDENT_ENV_VAR :== "CLEAN_PLATFORM_DEBUG_PERFORMANCE_INDENT_LEVEL"
measureTime :: !u:(*env -> *env) -> v:(*env -> (!Int, !Int, !*env)), [v <= u]
measureTime :: !u:(*env -> *env) -> v:(*env -> (Int, Int, *env)), [v <= u]
measureTime f = g
where
g env
......@@ -17,7 +17,7 @@ where
# env = f env
= ((), env)
measureTimeRes :: !u:(*env -> (!.a, !*env)) -> v:(*env -> (!Int, !Int, !.a, !*env)), [v <= u]
measureTimeRes :: !u:(*env -> (.a, *env)) -> v:(*env -> (Int, Int, .a, *env)), [v <= u]
measureTimeRes f = g
where