...
 
Commits (1)
......@@ -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
......@@ -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)
......@@ -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
......@@ -1269,7 +1269,7 @@ fromListWithKey f xs = foldl (ins f) newMap xs
//
// > 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`)
......
......@@ -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
// unsafe operations used, because we don't have *World, but arbitrary env
......@@ -42,7 +42,7 @@ where
# env = f env
= ((), env)
printTimeRes :: !String !u:(*env -> (!.a, !*env)) -> v:(*env -> (!.a, !*env)), [v <= u]
printTimeRes :: !String !u:(*env -> (.a, *env)) -> v:(*env -> (.a, *env)), [v <= u]
printTimeRes str f = g
where
// unsafe operations used, because we don't have *World, but arbitrary env
......@@ -64,7 +64,7 @@ where
= (x, env)
// used instead of accUnsafe to make sure that *env used by timing functions is evaluated
accUnsafe` :: !*(*World -> *(.a, !*World)) !*env -> (.a, !*env)
accUnsafe` :: !*(*World -> *(.a, *World)) !*env -> (.a, !*env)
accUnsafe` f env = accUnsafe (g env)
where
g env world
......
......@@ -52,7 +52,7 @@ instance updateArrElt {!}
* = (x, { array & [index] = elt` })
* where (x, elt`) = f array.[index]`
*/
class accArrElt a :: !(.e -> (!.x, !.e)) !Int !*(a .e) -> (!.x, !*(a .e))
class accArrElt a :: !(.e -> (.x, .e)) !Int !*(a .e) -> (!.x, !*(a .e))
instance accArrElt {}
instance accArrElt {!}
......
......@@ -38,7 +38,7 @@ instance updateArrElt {!}
# (e,array) = array![index]
= {array & [index] = f e}
class accArrElt a :: !(.e -> (!.x, !.e)) !Int !*(a .e) -> (!.x, !*(a .e))
class accArrElt a :: !(.e -> (.x, .e)) !Int !*(a .e) -> (!.x, !*(a .e))
instance accArrElt {}
where
......
......@@ -5,13 +5,13 @@ from Data.Functor import class Functor
from Control.Monad import class Monad
from StdOverloaded import class toString
:: IO a = IO .(*World -> *(a, !*World))
:: IO a = IO .(*World -> *(a, *World))
execIO :: !(IO a) !*World -> *World
evalIO :: !(IO a) !*World -> *(a, !*World)
withWorld :: (*World -> *(.a, !*World)) -> IO .a
withWorld :: (*World -> *(.a, *World)) -> IO .a
putStr :: String -> IO ()
......@@ -32,5 +32,5 @@ instance pure IO
instance <*> IO
instance Monad IO
unsafePerformIO :: !(*World -> *(.a, !*World)) -> .a
unsafePerformIOTrue :: !(*World -> *(a, !*World)) -> Bool
unsafePerformIO :: !(*World -> *(.a, *World)) -> .a
unsafePerformIOTrue :: !(*World -> *(a, *World)) -> Bool
......@@ -18,7 +18,7 @@ execIO (IO f) world
evalIO :: !(IO a) !*World -> *(a, !*World)
evalIO (IO f) world = f world
withWorld :: (*World -> *(.a, !*World)) -> IO .a
withWorld :: (*World -> *(.a, *World)) -> IO .a
withWorld f = IO f
instance Functor IO
......@@ -92,13 +92,13 @@ writeFileM name txt = withWorld f
# (ok, world) = fclose file world
= ((), world)
unsafePerformIO :: !(*World -> *(.a, !*World)) -> .a
unsafePerformIO :: !(*World -> *(.a, *World)) -> .a
unsafePerformIO f
# (x, world) = f make_world
| world_to_true world = x
| otherwise = abort "error in unsafePerformIO\n"
unsafePerformIOTrue :: !(*World -> *(a, !*World)) -> Bool
unsafePerformIOTrue :: !(*World -> *(a, *World)) -> Bool
unsafePerformIOTrue f
# (x, world) = f make_world
= world_to_true world
......
......@@ -17,7 +17,7 @@ appUnsafe :: !(*World -> *World) !.a -> .a
/**
* Execute a function with side effect and use its result as a pure expression.
*/
accUnsafe :: !*(*World -> *(.a, !*World)) -> .a
accUnsafe :: !*(*World -> *(.a, *World)) -> .a
/**
* Changes the type of the given argument.
......
......@@ -7,7 +7,7 @@ appUnsafe f a
| world_to_true (f newWorld) = a
| otherwise = abort "error in appUnsafe\n"
accUnsafe :: !*(*World -> *(.a, !*World)) -> .a
accUnsafe :: !*(*World -> *(.a, *World)) -> .a
accUnsafe f
# (a, world) = f newWorld
| world_to_true world = a
......
......@@ -23,7 +23,7 @@ decodeMimeMultipart boundary body
# parts = split ("\r\n" +++ "--" +++ boundary +++ "\r\n") body
= map parsePart parts
where
parsePart :: String -> ([(!String,!String)], String)
parsePart :: String -> ([(String,String)], String)
parsePart part
# index = indexOf "\r\n\r\n" part
| index < 1 = ([], part)
......
......@@ -26,7 +26,7 @@ from Data.GenEq import generic gEq
| JSONReal !Real
| JSONString !String
| JSONArray ![JSONNode]
| JSONObject ![(!String,!JSONNode)]
| JSONObject ![(String,JSONNode)]
| JSONRaw !String
| JSONError
/**
......@@ -156,7 +156,7 @@ JSONDecode{|CONS of {gcd_name}|} fx _ l=:[JSONArray [JSONString name:fields] :xs
JSONDecode{|CONS|} fx _ l = (Nothing, l)
JSONDecode{|PAIR|} fx fy _ l = d1 fy (fx False l) l
where
d1 :: !(Bool [JSONNode] -> (!Maybe b, ![JSONNode])) !(!Maybe a, ![JSONNode]) ![JSONNode]
d1 :: !(Bool [JSONNode] -> (Maybe b, [JSONNode])) !(!Maybe a, ![JSONNode]) ![JSONNode]
-> (!Maybe (PAIR a b), ![JSONNode])
d1 fy (Just x,xs) l = d2 x (fy False xs) l
d1 _ (Nothing, _) l = (Nothing, l)
......@@ -181,7 +181,7 @@ JSONDecode{|FIELD of {gfd_name}|} fx _ l =:[JSONObject fields]
(Just x, _) = (Just (FIELD x), l)
(_, _) = (Nothing, l)
where
findField :: !String ![(!String, !JSONNode)] -> [JSONNode]
findField :: !String ![(String, JSONNode)] -> [JSONNode]
findField match [(l,x):xs]
| l == match = [x]
| otherwise = findField match xs
......
......@@ -81,7 +81,7 @@ copyNode start (JSONObject items) buffer
#! (start, buffer) = copyObjectItems start items buffer
= (start + 1, {buffer & [start] = '}'})
where
copyObjectItems :: !Int ![(!String, !JSONNode)] !*String -> *(!Int, !*String)
copyObjectItems :: !Int ![(String, JSONNode)] !*String -> *(!Int, !*String)
copyObjectItems start [] buffer = (start,buffer)
copyObjectItems start [(l,x)] buffer
# (start,buffer) = let len = size l in (start + len + 3 , copyChars (start + 1) len l {buffer & [start] = '"', [start + len + 1] = '"', [start + len + 2] = ':'})
......@@ -319,7 +319,7 @@ where
= (JSONObject [], offset+1)
= parse_object_items offset [] offset input
where
parse_object_items :: !Int !*[(!{#Char}, !JSONNode)] !Int !{#Char} -> (!JSONNode,!Int)
parse_object_items :: !Int !*[({#Char}, JSONNode)] !Int !{#Char} -> (!JSONNode,!Int)
parse_object_items offset items offset_after_bracket_open input
| offset<size input
| input.[offset]=='"'
......@@ -363,7 +363,7 @@ where
= (jsonUnescape string, offset+1)
= ("",-1) // missing '"'
parse_object_items_after_label_and_colon :: !{#Char} !Int !*[(!{#Char}, !JSONNode)] !Int !{#Char} -> (!JSONNode,!Int)
parse_object_items_after_label_and_colon :: !{#Char} !Int !*[({#Char}, JSONNode)] !Int !{#Char} -> (!JSONNode,!Int)
parse_object_items_after_label_and_colon label offset items offset_after_brace_open input
#! (item,offset) = parse offset input
| offset<size input && input.[offset]==','
......@@ -531,7 +531,7 @@ JSONDecode{|UNIT|} _ l = (Just UNIT, l)
JSONDecode{|PAIR|} fx fy _ l = d1 fy (fx False l) l
where
d1 :: !(Bool [JSONNode] -> (!Maybe b, ![JSONNode])) !(!Maybe a, ![JSONNode]) ![JSONNode]
d1 :: !(Bool [JSONNode] -> (Maybe b, [JSONNode])) !(!Maybe a, ![JSONNode]) ![JSONNode]
-> (!Maybe (PAIR a b), ![JSONNode])
d1 fy (Just x,xs) l = d2 x (fy False xs) l
d1 _ (Nothing, _) l = (Nothing, l)
......@@ -575,7 +575,7 @@ JSONDecode{|FIELD of {gfd_name}|} fx _ l =:[JSONObject fields]
(Just x, _) = (Just (FIELD x), l)
(_, _) = (Nothing, l)
where
findField :: !String ![(!String, !JSONNode)] -> [JSONNode]
findField :: !String ![(String, JSONNode)] -> [JSONNode]
findField match [(l,x):xs]
| l == match = [x]
| otherwise = findField match xs
......@@ -708,7 +708,7 @@ JSONDecode{|{!}|} fx _ l =:[JSONArray items:xs]
_ = (Nothing, l)
JSONDecode{|{!}|} fx _ l = (Nothing, l)
decodeItems :: !(Bool [JSONNode] -> (!Maybe a, ![JSONNode])) ![JSONNode] -> Maybe [a]
decodeItems :: !(Bool [JSONNode] -> (Maybe a, [JSONNode])) ![JSONNode] -> Maybe [a]
decodeItems fx [] = Just []
decodeItems fx [ox:oxs] = case fx False [ox] of
(Just x, _) = case decodeItems fx oxs of
......@@ -753,7 +753,7 @@ where
| otherwise = Nothing
findNode _ _ = Nothing
findField :: !String ![(!String, !JSONNode)] -> Maybe JSONNode
findField :: !String ![(String, JSONNode)] -> Maybe JSONNode
findField s [] = Nothing
findField s [(l,x):xs] = if (l == s) (Just x) (findField s xs)
......
......@@ -9,7 +9,7 @@ import StdOverloaded, StdGeneric, Data.Either
from Data.Maybe import :: Maybe
from Data.Error import :: MaybeErrorString, :: MaybeError
:: XMLDoc = XMLDoc !(Maybe XMLURI) ![(!XMLNamespacePrefix,!XMLURI)] !XMLNode
:: XMLDoc = XMLDoc !(Maybe XMLURI) ![(XMLNamespacePrefix,XMLURI)] !XMLNode
:: XMLNode = XMLElem !XMLQName ![XMLAttr] ![XMLNode]
| XMLText !String
......
......@@ -10,7 +10,7 @@ uname name = XMLQName Nothing name
qname :: !XMLNamespacePrefix !String -> XMLQName
qname namespace name = XMLQName (Just namespace) name
addNamespaces :: !(Maybe XMLURI) [(!XMLNamespacePrefix,!String)] !XMLNode -> XMLNode
addNamespaces :: !(Maybe XMLURI) [(XMLNamespacePrefix,String)] !XMLNode -> XMLNode
addNamespaces mbDefaultNamespace namespaces (XMLElem qname attrs children)
# ns = map (\(prefix,uri) -> XMLAttr (XMLQName (Just "xmlns") prefix) uri) namespaces
# ns = case mbDefaultNamespace of
......
......@@ -55,7 +55,7 @@ writeFile :: !String !String !*env -> (!MaybeError FileError (), !*env) | FileSy
* @param file operation function
* @return file operation result
*/
withFile :: !String !Int (*File -> (!MaybeError FileError a,!*File)) !*env
withFile :: !String !Int (*File -> (MaybeError FileError a,*File)) !*env
-> (!MaybeError FileError a, !*env) | FileSystem env
/**
......
......@@ -60,7 +60,7 @@ writeFile :: !String !String !*env -> (!MaybeError FileError (), !*env) | FileSy
writeFile filename contents env =
withFile filename FWriteData (\file -> (Ok (), fwrites contents file)) env
withFile :: !String !Int (*File -> (!MaybeError FileError a,!*File)) !*env
withFile :: !String !Int (*File -> (MaybeError FileError a,*File)) !*env
-> (!MaybeError FileError a, !*env) | FileSystem env
withFile filename filemode operation env
# (ok,file,env) = fopen filename filemode env
......
......@@ -183,8 +183,8 @@ where
)
, world)
runProcessFork :: !( Int Int *World -> (!MaybeOSError a, !*World))
!(Int Int Int *World -> (!MaybeOSError a, !*World))
runProcessFork :: !( Int Int *World -> (MaybeOSError a, *World))
!(Int Int Int *World -> (MaybeOSError a, *World))
!*World
-> (!MaybeOSError a, !*World)
runProcessFork childProcess parentProcess world
......