Commit e0f2da8d authored by Steffen Michels's avatar Steffen Michels

Merge branch 'reduce-warnings' into 'master'

Reduce strictness annotation warnings

See merge request !261
parents 9fe0136c 09dd3c82
Pipeline #27572 passed with stage
in 3 minutes and 11 seconds
...@@ -98,7 +98,7 @@ instance docDescription ParamDoc ...@@ -98,7 +98,7 @@ instance docDescription ParamDoc
* the arguments (the second argument). The first argument is the name. * the arguments (the second argument). The first argument is the name.
*/ */
:: Property :: Property
= ForAll !String ![(!String,!Type)] !String = ForAll !String ![(String,Type)] !String
/** /**
* When a property type contains type variables, a `PropertyVarInstantiation` * When a property type contains type variables, a `PropertyVarInstantiation`
...@@ -251,7 +251,7 @@ parseDoc :: !String -> Either ParseError (!d, ![ParseWarning]) | docBlockToDoc{| ...@@ -251,7 +251,7 @@ parseDoc :: !String -> Either ParseError (!d, ![ParseWarning]) | docBlockToDoc{|
* @representation An order list of key-value pairs. A key can occur multiple * @representation An order list of key-value pairs. A key can occur multiple
* times. The description has key `description`. * times. The description has key `description`.
*/ */
:: DocBlock :== [(!String, !String)] :: DocBlock :== [(String, String)]
/** /**
* The magic for {{`parseDoc`}}. Usually, a record type like {{`FunctionDoc`}} * The magic for {{`parseDoc`}}. Usually, a record type like {{`FunctionDoc`}}
......
...@@ -186,7 +186,7 @@ where ...@@ -186,7 +186,7 @@ where
Left es -> Left (UnknownError "failed to parse property signature") Left es -> Left (UnknownError "failed to parse property signature")
Right (name,args) -> Right (ForAll name args, []) Right (name,args) -> Right (ForAll name args, [])
where where
parser :: Parser Char (!String, ![(!String, !Type)]) parser :: Parser Char (!String, ![(String, Type)])
parser = skipSpaces *> parser = skipSpaces *>
pMany (pSatisfy ((<>) ':')) >>= \name -> pMany (pSatisfy ((<>) ':')) >>= \name ->
skipSpaces *> pToken ':' *> skipSpaces *> pToken ':' *>
......
...@@ -109,7 +109,7 @@ where ...@@ -109,7 +109,7 @@ where
:: UnificationState = :: UnificationState =
{ assignments :: ![TVAssignment] { assignments :: ![TVAssignment]
, goals :: ![(!Type, !Type)] , goals :: ![(Type, Type)]
, used_universal_vars :: ![TypeVar] , used_universal_vars :: ![TypeVar]
} }
assignments s :== s.UnificationState.assignments assignments s :== s.UnificationState.assignments
......
...@@ -6,7 +6,7 @@ from Data.Functor import class Functor ...@@ -6,7 +6,7 @@ from Data.Functor import class Functor
from Control.Applicative import class pure, class <*>, class Applicative from Control.Applicative import class pure, class <*>, class Applicative
from Control.Monad import class Monad 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 foldrArr :: !(a .b -> .b) !.b !.(arr a) -> .b | Array arr a
......
...@@ -3,12 +3,12 @@ implementation module Data.Array ...@@ -3,12 +3,12 @@ implementation module Data.Array
import StdArray, StdInt, StdOverloaded, StdClass, StdFunctions import StdArray, StdInt, StdOverloaded, StdClass, StdFunctions
import Data.Functor, Control.Applicative, Control.Monad 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 mapArrSt f arr st
#! (sz, arr) = usize arr #! (sz, arr) = usize arr
= mapArrSt` sz 0 f arr st = mapArrSt` sz 0 f arr st
where 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 mapArrSt` sz idx f arr st
| idx == sz = (arr, st) | idx == sz = (arr, st)
| otherwise | otherwise
......
...@@ -50,13 +50,13 @@ instance asinh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ...@@ -50,13 +50,13 @@ instance asinh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a &
instance acosh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ln a instance acosh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ln a
instance atanh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ln a instance atanh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ln a
realPart :: (Complex a) -> a realPart :: !(Complex a) -> a
imagPart :: (Complex a) -> a imagPart :: !(Complex a) -> a
mkPolar :: a a -> Complex a | cos a & sin a & * a mkPolar :: a a -> Complex a | cos a & sin a & * a
cis :: a -> Complex a | cos a & sin a cis :: a -> Complex a | cos a & sin a
polar :: (Complex a) -> (a, a) | Ord a & Eq a & atan a & sqrt a & MultDiv a & PlusMin a & pi a polar :: (Complex a) -> (a, a) | Ord a & Eq a & atan a & sqrt a & MultDiv a & PlusMin a & pi a
magnitude :: (Complex a) -> a | sqrt a & * a & + a magnitude :: !(Complex a) -> a | sqrt a & * a & + a
phase :: (Complex a) -> a | Ord a & Eq a & atan a & MultDiv a & PlusMin a & pi a phase :: !(Complex a) -> a | Ord a & Eq a & atan a & MultDiv a & PlusMin a & pi a
conjugate :: (Complex a) -> Complex a | ~ a conjugate :: !(Complex a) -> Complex a | ~ a
...@@ -129,10 +129,10 @@ instance acosh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ...@@ -129,10 +129,10 @@ instance acosh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a &
instance atanh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ln a where instance atanh (Complex a) | Ord a & Eq a & AllGeo a & Arith a & pi a & sqrt a & ln a where
atanh z = (one/two) * ln ((one+z) / (one-z)) atanh z = (one/two) * ln ((one+z) / (one-z))
realPart :: (Complex a) -> a realPart :: !(Complex a) -> a
realPart (x :+ _) = x realPart (x :+ _) = x
imagPart :: (Complex a) -> a imagPart :: !(Complex a) -> a
imagPart (_ :+ x) = x imagPart (_ :+ x) = x
mkPolar :: a a -> Complex a | cos a & sin a & * a mkPolar :: a a -> Complex a | cos a & sin a & * a
...@@ -144,10 +144,10 @@ cis theta = cos theta :+ sin theta ...@@ -144,10 +144,10 @@ cis theta = cos theta :+ sin theta
polar :: (Complex a) -> (a, a) | Ord a & Eq a & atan a & sqrt a & MultDiv a & PlusMin a & pi a polar :: (Complex a) -> (a, a) | Ord a & Eq a & atan a & sqrt a & MultDiv a & PlusMin a & pi a
polar z = (magnitude z, phase z) polar z = (magnitude z, phase z)
magnitude :: (Complex a) -> a | sqrt a & * a & + a magnitude :: !(Complex a) -> a | sqrt a & * a & + a
magnitude (x :+ y) = sqrt (x*x + y*y) magnitude (x :+ y) = sqrt (x*x + y*y)
phase :: (Complex a) -> a | Ord a & Eq a & atan a & MultDiv a & PlusMin a & pi a phase :: !(Complex a) -> a | Ord a & Eq a & atan a & MultDiv a & PlusMin a & pi a
phase (x :+ y) phase (x :+ y)
| x > zero = atan (y/x) | x > zero = atan (y/x)
| x < zero && y >= zero = atan (y/x) + pi | x < zero && y >= zero = atan (y/x) + pi
...@@ -156,7 +156,7 @@ phase (x :+ y) ...@@ -156,7 +156,7 @@ phase (x :+ y)
| x == zero && y < zero = pi / two | x == zero && y < zero = pi / two
= undef = undef
conjugate :: (Complex a) -> Complex a | ~ a conjugate :: !(Complex a) -> Complex a | ~ a
conjugate (x :+ y) = x :+ (~y) conjugate (x :+ y) = x :+ (~y)
//Ugly //Ugly
......
...@@ -5,4 +5,4 @@ definition module Data.Data ...@@ -5,4 +5,4 @@ definition module Data.Data
// //
// Left True =+?= Left False == True // Left True =+?= Left False == True
// //
(=+?=) infix 6 :: a a -> Bool (=+?=) infix 6 :: !a !a -> Bool
...@@ -7,6 +7,6 @@ import StdOverloaded, StdCleanTypes, StdString ...@@ -7,6 +7,6 @@ import StdOverloaded, StdCleanTypes, StdString
// //
// Left True =+?= Left False == True // Left True =+?= Left False == True
// //
(=+?=) infix 6 :: a a -> Bool // TODO: this can probably be: pushD_a 0; pushD_a 1; pop_a 2; eqI
(=+?=) infix 6 :: !a !a -> Bool
(=+?=) l r = toString (CTToCons l) == toString (CTToCons r) (=+?=) l r = toString (CTToCons l) == toString (CTToCons r)
...@@ -5,4 +5,4 @@ from StdOverloaded import class == ...@@ -5,4 +5,4 @@ from StdOverloaded import class ==
encodeInt :: ![Int] -> [Int] encodeInt :: ![Int] -> [Int]
decodeInt :: ![Int] -> [Int] decodeInt :: ![Int] -> [Int]
encode :: ![a] -> [(Int, a)] | == a encode :: ![a] -> [(Int, a)] | == a
decode :: ![(!Int, !a)] -> [a] | == a decode :: ![(Int, a)] -> [a] | == a
...@@ -27,17 +27,17 @@ decodeInt xs = reverse (rldInt` xs []) ...@@ -27,17 +27,17 @@ decodeInt xs = reverse (rldInt` xs [])
encode :: ![a] -> [(Int, a)] | == a encode :: ![a] -> [(Int, a)] | == a
encode xs = reverse (rle` xs []) encode xs = reverse (rle` xs [])
where where
rle` :: ![a] ![(!Int, !a)] -> [(Int, a)] | == a rle` :: ![a] ![(Int, a)] -> [(Int, a)] | == a
rle` [] acc = acc rle` [] acc = acc
rle` [x:xs] [] = rle` xs [(1, x)] rle` [x:xs] [] = rle` xs [(1, x)]
rle` [x:xs] [t=:(n, y) : ys] rle` [x:xs] [t=:(n, y) : ys]
| x == y = rle` xs [(n + 1, y) : ys] | x == y = rle` xs [(n + 1, y) : ys]
| otherwise = rle` xs [(1, x) : t : ys] | otherwise = rle` xs [(1, x) : t : ys]
decode :: ![(!Int, !a)] -> [a] | == a decode :: ![(Int, a)] -> [a] | == a
decode xs = reverse (rld` xs []) decode xs = reverse (rld` xs [])
where where
rld` :: ![(!Int, !a)] ![a] -> [a] | == a rld` :: ![(Int, a)] ![a] -> [a] | == a
rld` [] acc = acc rld` [] acc = acc
rld` [(0, x) : xs] acc = rld` xs acc rld` [(0, x) : xs] acc = rld` xs acc
rld` [(n, x) : xs] acc = rld` [(n - 1, x) : xs] [x : 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 ...@@ -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 * @param The second operation, getting the result of the first as input
* @return The Error of the first or the second operation * @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. * 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 ...@@ -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 * @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 * @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 ...@@ -68,7 +68,7 @@ combineErrors a b combf = case a of
Error e = Error e Error e = Error e
Ok b = combf a b 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 seqErrorsSt aop bop st
# (a,st) = aop st # (a,st) = aop st
= case a of = case a of
...@@ -76,7 +76,7 @@ seqErrorsSt aop bop st ...@@ -76,7 +76,7 @@ seqErrorsSt aop bop st
Ok a = bop a 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 combineErrorsSt aop bop combf st
# (a,st) = aop st # (a,st) = aop st
= case a of = case a of
......
...@@ -52,7 +52,7 @@ seqSt :: !(a .st -> .st) ![a] !.st -> .st ...@@ -52,7 +52,7 @@ seqSt :: !(a .st -> .st) ![a] !.st -> .st
* @param The initial state. * @param The initial state.
* @result The value results and the final 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)`. * The fixed point combinator, reducing `fix f` to `f (fix f)`.
*/ */
......
...@@ -35,7 +35,7 @@ seqSt :: !(a .st -> .st) ![a] !.st -> .st ...@@ -35,7 +35,7 @@ seqSt :: !(a .st -> .st) ![a] !.st -> .st
seqSt f [] st = st seqSt f [] st = st
seqSt f [x:xs] st = seqSt f xs (f x 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 [] st = ([], st)
mapSt f [x:xs] st mapSt f [x:xs] st
# (y, st) = f x st # (y, st) = f x st
......
...@@ -62,7 +62,7 @@ setNodeData :: NodeIndex a u:(Graph a b) -> v:(Graph a b), [u <= v] ...@@ -62,7 +62,7 @@ setNodeData :: NodeIndex a u:(Graph a b) -> v:(Graph a b), [u <= v]
//Mapping //Mapping
mapNodes :: !(a -> b) !.(Graph a e) -> .(Graph b e) mapNodes :: !(a -> b) !.(Graph a e) -> .(Graph b e)
mapEdges :: !(a -> b) !.(Graph n a) -> .(Graph n b) 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 //Folding
foldrNodes :: (NodeIndex (Node n) .a -> .a) .a .(Graph n e) -> .a foldrNodes :: (NodeIndex (Node n) .a -> .a) .a .(Graph n e) -> .a
......
...@@ -224,7 +224,7 @@ where ...@@ -224,7 +224,7 @@ where
mapMap :: (a -> b) (Map k a) -> (Map k b) | Eq k & Ord k 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 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 } mapIndices updates { nodes, edges }
# updMap = fromList updates # updMap = fromList updates
= { Graph = { Graph
......
...@@ -25,15 +25,15 @@ instance == (Heap a) ...@@ -25,15 +25,15 @@ instance == (Heap a)
instance < (Heap a) instance < (Heap a)
instance Semigroup (Heap a) instance Semigroup (Heap a) where mappend :: !(Heap a) !(Heap a) -> Heap a
instance Monoid (Heap a) instance Monoid (Heap a)
:: Entry p a = Entry p a :: Entry p a = Entry p a
null :: (Heap a) -> Bool null :: !(Heap a) -> Bool
size :: (Heap a) -> Int size :: !(Heap a) -> Int
//* @type Heap a //* @type Heap a
empty :== Empty empty :== Empty
...@@ -47,32 +47,32 @@ singletonWith f a :== Heap 1 f (Node 0 a Nil) ...@@ -47,32 +47,32 @@ singletonWith f a :== Heap 1 f (Node 0 a Nil)
//* @type a (Heap a) -> (Heap a) | Ord a //* @type a (Heap a) -> (Heap a) | Ord a
insert :== insertWith (<=) insert :== insertWith (<=)
insertWith :: (a a -> Bool) a (Heap a) -> Heap a insertWith :: (a a -> Bool) a !(Heap a) -> Heap a
union :: (Heap a) (Heap a) -> Heap a union :: !(Heap a) !(Heap a) -> Heap a
replicate :: a Int -> Heap a | Ord a replicate :: a !Int -> Heap a | Ord a
uncons :: (Heap a) -> Maybe (a, Heap a) | Ord a uncons :: !(Heap a) -> Maybe (a, Heap a) | Ord a
//* @type (Heap a) -> Maybe (a, Heap a) | Ord a //* @type (Heap a) -> Maybe (a, Heap a) | Ord a
viewMin :== uncons viewMin :== uncons
minimum :: (Heap a) -> a minimum :: !(Heap a) -> a
trees :: (Forest a) -> [Tree a] trees :: !(Forest a) -> [Tree a]
deleteMin :: (Heap a) -> Heap a deleteMin :: !(Heap a) -> Heap a
map :: (a -> b) (Heap a) -> Heap b | Ord b map :: (a -> b) !(Heap a) -> Heap b | Ord b
mapMonotonic :: (a -> b) (Heap a) -> Heap b | Ord b mapMonotonic :: (a -> b) !(Heap a) -> Heap b | Ord b
filter :: (a -> Bool) (Heap a) -> Heap a filter :: (a -> Bool) !(Heap a) -> Heap a
partition :: (a -> Bool) (Heap a) -> (Heap a, Heap a) partition :: (a -> Bool) !(Heap a) -> (Heap a, Heap a)
split :: a (Heap a) -> (Heap a, Heap a, Heap a) split :: a !(Heap a) -> (Heap a, Heap a, Heap a)
//* @type Int (Heap a) -> Heap a //* @type Int (Heap a) -> Heap a
take :== withList o 'Data.List'.take take :== withList o 'Data.List'.take
...@@ -95,18 +95,18 @@ takeWhile :== withList o 'Data.List'.takeWhile ...@@ -95,18 +95,18 @@ takeWhile :== withList o 'Data.List'.takeWhile
//* @type (a -> Bool) (Heap a) -> Heap a //* @type (a -> Bool) (Heap a) -> Heap a
dropWhile :== withList o 'Data.List'.dropWhile dropWhile :== withList o 'Data.List'.dropWhile
nub :: (Heap a) -> Heap a nub :: !(Heap a) -> Heap a
concatMap :: (a -> Heap b) (Heap a) -> Heap b | Ord b concatMap :: (a -> Heap b) !(Heap a) -> Heap b | Ord b
group :: (Heap a) -> Heap (Heap a) group :: !(Heap a) -> Heap (Heap a)
groupBy :: (a a -> Bool) (Heap a) -> Heap (Heap a) groupBy :: (a a -> Bool) !(Heap a) -> Heap (Heap a)
intersect :: (Heap a) (Heap a) -> Heap a intersect :: !(Heap a) (Heap a) -> Heap a
intersectWith :: (a a -> b) (Heap a) (Heap a) -> Heap b | Ord b intersectWith :: (a a -> b) !(Heap a) (Heap a) -> Heap b | Ord b
withList :: ([a] -> [a]) (Heap a) -> Heap a withList :: ([a] -> [a]) !(Heap a) -> Heap a
splitWithList :: ([a] -> ([a], [a])) (Heap a) -> (Heap a, Heap a) splitWithList :: ([a] -> ([a], [a])) !(Heap a) -> (Heap a, Heap a)
...@@ -72,7 +72,7 @@ instance < (Heap a) where ...@@ -72,7 +72,7 @@ instance < (Heap a) where
// //
// >>> null (singleton "hello") // >>> null (singleton "hello")
// False // False
null :: (Heap a) -> Bool null :: !(Heap a) -> Bool
null Empty = True null Empty = True
null _ = False null _ = False
...@@ -84,7 +84,7 @@ null _ = False ...@@ -84,7 +84,7 @@ null _ = False
// 1 // 1
// >>> size (fromList [4,1,2]) // >>> size (fromList [4,1,2])
// 3 // 3
size :: (Heap a) -> Int size :: !(Heap a) -> Int
size Empty = 0 size Empty = 0
size (Heap s _ _) = s size (Heap s _ _) = s
...@@ -124,7 +124,7 @@ singletonWith f a :== Heap 1 f (Node 0 a Nil) ...@@ -124,7 +124,7 @@ singletonWith f a :== Heap 1 f (Node 0 a Nil)
//insert :: a (Heap a) -> (Heap a) | Ord a //insert :: a (Heap a) -> (Heap a) | Ord a
insert :== insertWith (<=) insert :== insertWith (<=)
insertWith :: (a a -> Bool) a (Heap a) -> Heap a insertWith :: (a a -> Bool) a !(Heap a) -> Heap a
insertWith leq x Empty = singletonWith leq x insertWith leq x Empty = singletonWith leq x
insertWith leq x (Heap s _ t=:(Node _ y f)) insertWith leq x (Heap s _ t=:(Node _ y f))
| leq x y = Heap (s + 1) leq (Node 0 x (Cons t Nil)) | leq x y = Heap (s + 1) leq (Node 0 x (Cons t Nil))
...@@ -136,7 +136,7 @@ insertWith leq x (Heap s _ t=:(Node _ y f)) ...@@ -136,7 +136,7 @@ insertWith leq x (Heap s _ t=:(Node _ y f))
// fromList [1,2,6,4,3,5] // fromList [1,2,6,4,3,5]
// >>> union (fromList [1,1,1]) (fromList [1,2,1]) // >>> union (fromList [1,1,1]) (fromList [1,2,1])
// fromList [1,1,1,2,1,1] // fromList [1,1,1,2,1,1]
union :: (Heap a) (Heap a) -> Heap a union :: !(Heap a) !(Heap a) -> Heap a
union Empty q = q union Empty q = q
union q Empty = q union q Empty = q
union (Heap s1 leq t1=:(Node _ x1 f1)) (Heap s2 _ t2=:(Node _ x2 f2)) union (Heap s1 leq t1=:(Node _ x1 f1)) (Heap s2 _ t2=:(Node _ x2 f2))
...@@ -148,7 +148,7 @@ union _ _ = abort "error in union\n" ...@@ -148,7 +148,7 @@ union _ _ = abort "error in union\n"
// //
// >>> replicate 'a' 10 // >>> replicate 'a' 10
// fromList "aaaaaaaaaa" // fromList "aaaaaaaaaa"
replicate :: a Int -> Heap a | Ord a replicate :: a !Int -> Heap a | Ord a
replicate x0 y0 = fromList (repeatn y0 x0) replicate x0 y0 = fromList (repeatn y0 x0)
//| y0 < 0 = abort "Heap.replicate: negative length" //| y0 < 0 = abort "Heap.replicate: negative length"
//| y0 == 0 = mempty