Commit 43ce96d5 authored by Steffen Michels's avatar Steffen Michels

Merge branch 'strictness' into 'master'

Add derived strictness information that was not exported yet

See merge request !236
parents 2e427890 e9b0f49b
Pipeline #17546 passed with stage
in 3 minutes and 19 seconds
......@@ -268,7 +268,7 @@ printDoc :: !d -> String | docToDocBlock{|*|} d
* The magic for {{`printDoc`}}.
* @param If true, return a `Left`. If false, return a `Right`.
*/
generic docToDocBlock d :: Bool d -> Either [String] DocBlock
generic docToDocBlock d :: !Bool !d -> Either [String] DocBlock
derive docToDocBlock ModuleDoc, FunctionDoc, ClassMemberDoc, ClassDoc,
ConstructorDoc, TypeDoc
......
......@@ -242,7 +242,7 @@ where
fields = filter ((<>) "description" o fst) fields`
desc = lookup "description" fields`
generic docToDocBlock a :: Bool a -> Either [String] DocBlock
generic docToDocBlock a :: !Bool !a -> Either [String] DocBlock
docToDocBlock{|String|} True s = Left [s]
docToDocBlock{|String|} _ _ = abort "error in docToDocBlock{|String|}\n"
docToDocBlock{|[]|} fx True xs = Left [x \\ Left xs` <- map (fx True) xs, x <- xs`]
......
......@@ -8,6 +8,7 @@ from Data.Maybe import :: Maybe
class MonadFix m | Monad m where
mfix :: (a -> m a) -> m a
instance MonadFix Maybe
instance MonadFix Maybe where
mfix :: !(a -> Maybe a) -> Maybe a
instance MonadFix []
......@@ -9,6 +9,7 @@ import Data.List
import Data.Maybe
instance MonadFix Maybe where
mfix :: !(a -> Maybe a) -> Maybe a
mfix f =
let a = f (unJust a) in a
where unJust (Just x) = x
......
......@@ -11,7 +11,7 @@ from Data.Monoid import class Monoid, class Semigroup
:: RWS r w s a :== RWST r w s Identity a
// The RWST monad transformer
:: RWST r w s m a = RWST (r s -> m (a, s, w))
:: RWST r w s m a = RWST !(r s -> m (a, s, w))
instance Functor (RWST r w s m) | Monad m & Monoid w
instance pure (RWST r w s m) | pure m & Monoid w
......@@ -26,9 +26,9 @@ execRWS :: (RWS r w s a) r s -> (s, w)
mapRWS :: ((a, s, w) -> (b, s, w`)) (RWS r w s a) -> RWS r w` s b
withRWS :: (r` s -> (r, s)) (RWS r w s a) -> RWS r` w s a
runRWST :: (RWST r w s m a) r s -> m (a, s, w)
evalRWST :: (RWST r w s m a) r s -> m (a, w) | Monad m
execRWST :: (RWST r w s m a) r s -> m (s, w) | Monad m
runRWST :: !(RWST r w s m a) r s -> m (a, s, w)
evalRWST :: !(RWST r w s m a) r s -> m (a, w) | Monad m
execRWST :: !(RWST r w s m a) r s -> m (s, w) | Monad m
mapRWST :: ((m (a, s, w)) -> n (b, s, w`)) (RWST r w s m a) -> RWST r w` s n b
withRWST :: (r` -> s -> (r, s)) (RWST r w s m a) -> RWST r` w s m a
......
......@@ -53,18 +53,15 @@ mapRWS f m = mapRWST (Identity o f o runIdentity) m
withRWS :: (r` s -> (r, s)) (RWS r w s a) -> RWS r` w s a
withRWS f m = withRWST f m
// The RWST monad transformer
:: RWST r w s m a = RWST (r s -> m (a, s, w))
runRWST :: (RWST r w s m a) r s -> m (a, s, w)
runRWST :: !(RWST r w s m a) r s -> m (a, s, w)
runRWST (RWST f) r s = f r s
evalRWST :: (RWST r w s m a) r s -> m (a, w) | Monad m
evalRWST :: !(RWST r w s m a) r s -> m (a, w) | Monad m
evalRWST m r s
= runRWST m r s
>>= \(a, _, w) -> pure (a, w)
execRWST :: (RWST r w s m a) r s -> m (s, w) | Monad m
execRWST :: !(RWST r w s m a) r s -> m (s, w) | Monad m
execRWST m r s
= runRWST m r s
>>= \(_, s`, w) -> pure (s`, w)
......
......@@ -6,18 +6,18 @@ from Control.Monad.Trans import class MonadTrans
from Data.Functor import class Functor
from Data.Functor.Identity import :: Identity
:: ReaderT r m a = ReaderT (r -> m a)
:: ReaderT r m a = ReaderT !(r -> m a)
:: Reader r a :== ReaderT r Identity a
runReaderT :: .(ReaderT .a u:b .c) -> .a -> u:(b .c)
runReaderT :: !.(ReaderT .a u:b .c) -> .a -> u:(b .c)
reader :: (.a -> .b) -> .(ReaderT .a .Identity .b)
runReader :: .(ReaderT .a u:Identity v:b) -> .(.a -> v:b), [u <= v]
mapReaderT :: (u:(a .b) -> v:(c .d)) .(ReaderT .e u:a .b) -> .(ReaderT .e v:c .d)
mapReader :: (u:a -> .b) -> .(.(ReaderT .c v:Identity u:a) -> .(ReaderT .c .Identity .b)), [v <= u]
withReaderT :: (.a -> .b) .(ReaderT .b .c .d) -> .(ReaderT .a .c .d)
withReader :: u:((.a -> .b) -> v:(.(ReaderT .b .c .d) -> .(ReaderT .a .c .d))), [v <= u]
liftReaderT :: (a .b) -> .(ReaderT .c a .b)
liftReaderT :: !(a .b) -> .(ReaderT .c a .b)
ask :: .(ReaderT a b a) | Monad b
local :: u:((.a -> .b) -> v:(.(ReaderT .b .c .d) -> .(ReaderT .a .c .d))), [v <= u]
asks :: (a -> b) -> ReaderT a c b | Monad c
......@@ -28,3 +28,5 @@ instance <*> (ReaderT r m) | Monad m
instance Monad (ReaderT r m) | Monad m
instance MonadTrans (ReaderT r)
where
liftT :: !(m a) -> ReaderT r m a | Monad m
......@@ -6,10 +6,6 @@ import Control.Applicative
from StdFunc import o, const
import Control.Monad.Trans
:: ReaderT r m a = ReaderT (r -> m a)
:: Reader r a :== ReaderT r Identity a
instance Functor (ReaderT r m) | Monad m where
fmap f m = liftM f m
......@@ -24,10 +20,12 @@ where
instance Monad (ReaderT r m) | Monad m where
bind m k = ReaderT (\r -> runReaderT m r >>= \a -> runReaderT (k a) r)
instance MonadTrans (ReaderT r) where
liftT r = liftReaderT r
instance MonadTrans (ReaderT r)
where
liftT :: !(m a) -> ReaderT r m a | Monad m
liftT r = liftReaderT r
runReaderT :: .(ReaderT .a u:b .c) -> .a -> u:(b .c)
runReaderT :: !.(ReaderT .a u:b .c) -> .a -> u:(b .c)
runReaderT (ReaderT f) = f
reader :: (.a -> .b) -> .(ReaderT .a .Identity .b)
......@@ -48,7 +46,7 @@ mapReaderT f m = ReaderT (f o runReaderT m)
withReaderT :: (.a -> .b) .(ReaderT .b .c .d) -> .(ReaderT .a .c .d)
withReaderT f m = ReaderT (runReaderT m o f)
liftReaderT :: (a .b) -> .(ReaderT .c a .b)
liftReaderT :: !(a .b) -> .(ReaderT .c a .b)
liftReaderT m = ReaderT (const m)
ask :: .(ReaderT a b a) | Monad b
......
......@@ -7,7 +7,7 @@ from Control.Monad.Trans import class MonadTrans
from Data.Functor import class Functor
from Data.Functor.Identity import :: Identity
:: WriterT w m a = WriterT (m (a, w))
:: WriterT w m a = WriterT !(m (a, w))
:: Writer w a :== WriterT w Identity a
......@@ -17,17 +17,18 @@ instance <*> (WriterT w m) | Monad m & Monoid w
instance Monad (WriterT w m) | Monad m & Monoid w
instance MonadTrans (WriterT w) | Monoid w
where
liftT :: !(m b) -> WriterT w m b | Monoid w & Monad m
runWriterT :: (WriterT a u:b c) -> u:(b (c,a))
runWriterT :: !(WriterT a u:b c) -> u:(b (c,a))
writer :: .(.(a,b) -> WriterT b .Identity a)
runWriter :: .((WriterT a .Identity b) -> (b,a))
execWriter :: (WriterT a .Identity b) -> a
mapWriter :: u:((a,b) -> .(c,d)) -> v:((WriterT b .Identity a) -> WriterT d .Identity c), [v <= u]
execWriterT :: .(WriterT a b c) -> b a | Monad b
mapWriterT :: .(u:(a (b,c)) -> v:(d (e,f))) (WriterT c u:a b) -> WriterT f v:d e
execWriterT :: !.(WriterT a b c) -> b a | Monad b
mapWriterT :: !.(u:(a (b,c)) -> v:(d (e,f))) (WriterT c u:a b) -> WriterT f v:d e
tell :: a -> .(WriterT a b ()) | Monad b
listen :: .(WriterT a b c) -> .(WriterT a b (c,a)) | Monad b
pass :: .(WriterT a b (c,a -> d)) -> .(WriterT d b c) | Monad b
listens :: (a -> b) .(WriterT a c d) -> WriterT a c (d,b) | Monad c & Monoid a
censor :: (a -> b) .(WriterT a c d) -> .(WriterT b c d) | Monad c & Monoid a
listen :: !.(WriterT a b c) -> .(WriterT a b (c,a)) | Monad b
pass :: !.(WriterT a b (c,a -> d)) -> .(WriterT d b c) | Monad b
listens :: (a -> b) !.(WriterT a c d) -> WriterT a c (d,b) | Monad c & Monoid a
censor :: (a -> b) !.(WriterT a c d) -> .(WriterT b c d) | Monad c & Monoid a
......@@ -8,10 +8,6 @@ import Control.Monad.Trans
from StdFunc import o
from StdTuple import fst, snd
:: WriterT w m a = WriterT (m (a, w))
:: Writer w a :== WriterT w Identity a
instance Functor (WriterT w m) | Monad m & Monoid w where
fmap f m = liftM f m
......@@ -28,10 +24,12 @@ instance Monad (WriterT w m) | Monad m & Monoid w where
runWriterT (k a) >>= \(b, w`) ->
pure (b, mappend w w`))
instance MonadTrans (WriterT w) | Monoid w where
liftT m = WriterT (m >>= \a -> pure (a, mempty))
instance MonadTrans (WriterT w) | Monoid w
where
liftT :: !(m b) -> WriterT w m b | Monoid w & Monad m
liftT m = WriterT (m >>= \a -> pure (a, mempty))
runWriterT :: (WriterT a u:b c) -> u:(b (c,a))
runWriterT :: !(WriterT a u:b c) -> u:(b (c,a))
runWriterT (WriterT w) = w
writer :: .(.(a,b) -> WriterT b .Identity a)
......@@ -46,25 +44,25 @@ execWriter m = snd (runWriter m)
mapWriter :: u:((a,b) -> .(c,d)) -> v:((WriterT b .Identity a) -> WriterT d .Identity c), [v <= u]
mapWriter f = mapWriterT (Identity o f o runIdentity)
execWriterT :: .(WriterT a b c) -> b a | Monad b
execWriterT :: !.(WriterT a b c) -> b a | Monad b
execWriterT m = runWriterT m >>= \(_, w) -> pure w
mapWriterT :: .(u:(a (b,c)) -> v:(d (e,f))) (WriterT c u:a b) -> WriterT f v:d e
mapWriterT :: !.(u:(a (b,c)) -> v:(d (e,f))) (WriterT c u:a b) -> WriterT f v:d e
mapWriterT f m = WriterT (f (runWriterT m))
tell :: a -> .(WriterT a b ()) | Monad b
tell w = WriterT (pure ((), w))
listen :: .(WriterT a b c) -> .(WriterT a b (c,a)) | Monad b
listen :: !.(WriterT a b c) -> .(WriterT a b (c,a)) | Monad b
listen m = WriterT (runWriterT m >>= \(a, w) ->
pure ((a, w), w))
pass :: .(WriterT a b (c,a -> d)) -> .(WriterT d b c) | Monad b
pass :: !.(WriterT a b (c,a -> d)) -> .(WriterT d b c) | Monad b
pass m = WriterT (runWriterT m >>= \((a, f), w) ->
pure (a, f w))
listens :: (a -> b) .(WriterT a c d) -> WriterT a c (d,b) | Monad c & Monoid a
listens :: (a -> b) !.(WriterT a c d) -> WriterT a c (d,b) | Monad c & Monoid a
listens f m = listen m >>= \(a, w) -> pure (a, f w)
censor :: (a -> b) .(WriterT a c d) -> .(WriterT b c d) | Monad c & Monoid a
censor :: (a -> b) !.(WriterT a c d) -> .(WriterT b c d) | Monad c & Monoid a
censor f m = pass (m >>= \a -> pure (a, f))
......@@ -18,7 +18,7 @@ from System.File import :: FileError
* @param The message for which to compute the digest
* @return The ascii hex representation of the message digest
*/
md5 :: String -> String
md5 :: !String -> String
/**
* Compute the MD5 digest of a string
......@@ -26,7 +26,7 @@ md5 :: String -> String
* @param The message for which to compute the digest
* @return The raw 128 bit digest
*/
md5StringDigest :: String -> MD5Digest
md5StringDigest :: !String -> MD5Digest
/**
* Compute the MD5 digest of the contents of a file
......@@ -36,7 +36,7 @@ md5StringDigest :: String -> MD5Digest
* @return The raw 128 bit digest
* @return The environment
*/
md5FileDigest :: FilePath *env -> (!MaybeError FileError MD5Digest,!*env) | FileSystem env
md5FileDigest :: !FilePath !*env -> (!MaybeError FileError MD5Digest,!*env) | FileSystem env
/**
* Print an MD5 digest as ascii hexadecimal form
......
......@@ -6,7 +6,7 @@ implementation module Crypto.Hash.MD5
import StdEnv
import Data.Tuple, Text, System.FilePath, System.File, Data.Error, Data.Functor
md5 :: String -> String
md5 :: !String -> String
md5 msg = toString (md5StringDigest msg)
/* "the values of the integer part of 4294967296 times abs(sin(i))" */
......@@ -207,8 +207,8 @@ readResult :: (Int,Int,Int,Int) -> MD5Digest
readResult (x,y,z,zs)
= MD5Digest (join "" [{toChar (i >> (j * 8)) \\ j <- [0..3]} \\ i <- [x,y,z,zs]])
md5StringDigest :: String -> MD5Digest
md5StringDigest msg
md5StringDigest :: !String -> MD5Digest
md5StringDigest msg
# (result,buffer) = computeForString msg (0x67452301,0xefcdab89,0x98badcfe,0x10325476) ((size msg)*8) (createArray 16 0)
= result
......@@ -256,7 +256,7 @@ readS szoveg numberOfBits buffer
third = select text (index*4+2)
fourth = select text (index*4+3)
md5FileDigest :: FilePath *env -> (!MaybeError FileError MD5Digest,!*env) | FileSystem env
md5FileDigest :: !FilePath !*env -> (!MaybeError FileError MD5Digest,!*env) | FileSystem env
md5FileDigest path world
#!(ok,f,world)= fopen path FReadData world
|not ok
......
......@@ -12,10 +12,10 @@ foldrArr :: !(a .b -> .b) !.b !.(arr a) -> .b | Array arr a
foldrArrWithKey :: !(Int a -> .(.b -> .b)) !.b !.(arr a) -> .b | Array arr a
foldrUArr :: !(a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b *(arr a)
foldrUArr :: !(a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b !*(arr a)
-> *(.b, *(arr a)) | Array arr a
foldrUArrWithKey :: !(Int a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b *(arr a)
foldrUArrWithKey :: !(Int a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b !*(arr a)
-> *(.b, *(arr a)) | Array arr a
foldlArr :: !(.b a -> .b) !.b !.(arr a) -> .b | Array arr a
......@@ -33,8 +33,9 @@ appendArr :: !(arr a) !(arr a) -> arr a | Array arr a
instance +++ (arr a) | Array arr a
instance Functor {}, {!}
instance pure {}, {!}
instance pure {}
instance pure {!} where pure :: !a -> {!a}
instance <*> {}, {!}
instance Monad {}, {!}
reduceArray :: ((.a -> u:(b -> b)) -> .(b -> .(c -> .a))) (.a -> u:(b -> b)) b .(d c) -> b | Array d c
reduceArray :: ((.a -> u:(b -> b)) -> .(b -> .(c -> .a))) (.a -> u:(b -> b)) b !.(d c) -> b | Array d c
......@@ -32,11 +32,11 @@ foldrArrWithKey f b arr
#! (e, arr) = arr![idx]
= f idx e (foldrArr` arrSz (idx + 1) f b arr)
foldrUArr :: !(a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b *(arr a)
foldrUArr :: !(a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b !*(arr a)
-> *(.b, *(arr a)) | Array arr a
foldrUArr f b arr = foldrUArrWithKey (\_ -> f) b arr
foldrUArrWithKey :: !(Int a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b *(arr a)
foldrUArrWithKey :: !(Int a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b !*(arr a)
-> *(.b, *(arr a)) | Array arr a
foldrUArrWithKey f b arr
# (sz, arr) = usize arr
......@@ -99,14 +99,13 @@ mapArr f arr
appendArr :: !(arr a) !(arr a) -> arr a | Array arr a
appendArr l r
#! szl = size l
#! szr = size r
#! totalSz = szl + szr
#! totalSz = szl + size r
| totalSz < 1 = l
| otherwise
#! el = if (szl > 0) l.[0] r.[0]
#! newArr = createArray totalSz el
#! newArr = addWithOffset totalSz 0 l newArr
#! newArr = addWithOffset totalSz (szl - 1) r newArr
# newArr = addWithOffset totalSz (szl - 1) r newArr
= newArr
where
addWithOffset totalSz offset oldArr newArr
......@@ -128,6 +127,7 @@ where
instance pure {!}
where
pure :: !a -> {!a}
pure x = {!x}
instance <*> {!}
......@@ -137,7 +137,7 @@ where
instance Monad {} where bind m k = foldrArr ((+++) o k) {} m
instance Monad {!} where bind m k = foldrArr ((+++) o k) {} m
reduceArray :: ((.a -> u:(b -> b)) -> .(b -> .(c -> .a))) (.a -> u:(b -> b)) b .(d c) -> b | Array d c
reduceArray :: ((.a -> u:(b -> b)) -> .(b -> .(c -> .a))) (.a -> u:(b -> b)) b !.(d c) -> b | Array d c
reduceArray f op e xs
= reduce f 0 (size xs) op e xs
where
......
......@@ -26,12 +26,12 @@ instance == DiffStatus
/**
* Recursively set the status in a Diff.
*/
setStatus :: DiffStatus Diff -> Diff
setStatus :: !DiffStatus !Diff -> Diff
/**
* Compute the {{`Diff`}} between two values.
*/
generic gDiff a :: a a -> [Diff]
generic gDiff a :: !a !a -> [Diff]
derive gDiff UNIT, PAIR, EITHER, OBJECT, CONS of d, RECORD of d, FIELD of d
derive gDiff Int, Char, Bool, Real, String
derive gDiff [], [!], [ !], [!!], {}, {!}
......
......@@ -23,10 +23,10 @@ where
== OnlyLeft OnlyLeft = True
== _ _ = False
setStatus :: DiffStatus Diff -> Diff
setStatus :: !DiffStatus !Diff -> Diff
setStatus s d = {d & status=s, children=map (setStatus s) d.children}
generic gDiff a :: a a -> [Diff]
generic gDiff a :: !a !a -> [Diff]
gDiff{|Int|} x y = eqDiff x y
gDiff{|Char|} x y = eqDiff x y
gDiff{|Bool|} x y = eqDiff x y
......
......@@ -3,7 +3,7 @@
definition module Data.Graph.Inductive.Graph
from Data.Maybe import :: Maybe
from StdOverloaded import class <, class ==
from StdOverloaded import class <, class ==, class toString
from StdClass import class Eq
from Data.GenLexOrd import generic gLexOrd, :: LexOrd
......
......@@ -56,13 +56,13 @@ where
foldr a b c = 'StdList'.foldr a b c
foldr` f x y = strictFoldr f x y
where
strictFoldr :: !(.a -> .(.b -> .b)) !.b ![.a] -> .b
strictFoldr :: (.a -> .(.b -> .b)) !.b ![.a] -> .b
strictFoldr _ b [] = b
strictFoldr f b [x:xs] = f x (strictFoldr f b xs)
foldl` f x y = strictFoldl f x y
where
strictFoldl :: !(.a -> .(.b -> .a)) !.a ![.b] -> .a
strictFoldl :: (.a -> .(.b -> .a)) !.a ![.b] -> .a
strictFoldl _ b [] = b
strictFoldl f b [x:xs] = strictFoldl f (f b x) xs
......
......@@ -41,13 +41,34 @@ instance Monoid ()
:: Last a = Last (Maybe a)
instance Semigroup (Dual a) | Semigroup a
where
mappend :: !(Dual a) !(Dual a) -> Dual a | Semigroup a
instance Semigroup (Endo .a)
where
mappend :: !(Endo .a) !(Endo .a) -> Endo .a
instance Semigroup All
where
mappend :: !All !All -> All
instance Semigroup Any
instance Semigroup (Sum a) | + a & zero a
instance Semigroup (Product a) | * a & one a
where
mappend :: !Any !Any -> Any
instance Semigroup (Sum a) | +, zero a
where
mappend :: !(Sum a) !(Sum a) -> Sum a | +, zero a
instance Semigroup (Product a) | *, one a
where
mappend :: !(Product a) !(Product a) -> Product a | *, one a
instance Semigroup (First a)
instance Semigroup (Last a)
where
mappend :: !(Last a) !(Last a) -> Last a
instance Monoid (Dual a) | Monoid a
instance Monoid (Endo .a)
......
......@@ -6,61 +6,86 @@ from StdFunc import o, id
from Data.Maybe import :: Maybe(..)
from StdList import ++
instance Semigroup () where
mappend _ _ = ()
instance Monoid () where
mempty = ()
instance Semigroup (Dual a) | Semigroup a where
mappend (Dual x) (Dual y) = Dual (mappend y x)
instance Monoid (Dual a) | Monoid a where
mempty = Dual mempty
instance Semigroup (Endo .a) where
mappend (Endo f) (Endo g) = Endo (f o g)
instance Monoid (Endo .a) where
mempty = Endo id
instance Semigroup All where
mappend (All x) (All y) = All (x && y)
instance Monoid All where
mempty = All True
instance Semigroup Any where
mappend (Any x) (Any y) = Any (x || y)
instance Monoid Any where
mempty = Any False
instance Semigroup (Sum a) | + a & zero a where
mappend (Sum x) (Sum y) = Sum (x + y)
instance Monoid (Sum a) | + a & zero a where
mempty = Sum zero
instance Semigroup (Product a) | * a & one a where
mappend (Product x) (Product y) = Product (x * y)
instance Monoid (Product a) | * a & one a where
mempty = Product one
instance Semigroup (First a) where
mappend r=:(First (Just _)) _ = r
mappend (First Nothing) r = r
instance Monoid (First a) where
mempty = First Nothing
instance Semigroup (Last a) where
mappend _ r=:(Last (Just _)) = r
mappend r (Last Nothing) = r
instance Monoid (Last a) where
mempty = Last Nothing
instance Semigroup ()
where
mappend _ _ = ()
instance Monoid ()
where
mempty = ()
instance Semigroup (Dual a) | Semigroup a
where
mappend :: !(Dual a) !(Dual a) -> Dual a | Semigroup a
mappend (Dual x) (Dual y) = Dual (mappend y x)
instance Monoid (Dual a) | Monoid a
where
mempty = Dual mempty
instance Semigroup (Endo .a)
where
mappend :: !(Endo .a) !(Endo .a) -> Endo .a
mappend (Endo f) (Endo g) = Endo (f o g)
instance Monoid (Endo .a)
where
mempty = Endo id
instance Semigroup All
where
mappend :: !All !All -> All
mappend (All x) (All y) = All (x && y)
instance Monoid All
where
mempty = All True
instance Semigroup Any
where
mappend :: !Any !Any -> Any
mappend (Any x) (Any y) = Any (x || y)
instance Monoid Any
where
mempty = Any False
instance Semigroup (Sum a) | +, zero a
where
mappend :: !(Sum a) !(Sum a) -> Sum a | +, zero a
mappend (Sum x) (Sum y) = Sum (x + y)
instance Monoid (Sum a) | + a & zero a
where
mempty = Sum zero
instance Semigroup (Product a) | *, one a
where
mappend :: !(Product a) !(Product a) -> Product a | *, one a
mappend (Product x) (Product y) = Product (x * y)
instance Monoid (Product a) | * a & one a
where
mempty = Product one
instance Semigroup (First a)
where
mappend r=:(First (Just _)) _ = r
mappend (First Nothing) r = r
instance Monoid (First a)
where
mempty = First Nothing
instance Semigroup (Last a)
where
mappend :: !(Last a) !(Last a) -> Last a
mappend _ r=:(Last (Just _)) = r
mappend r (Last Nothing) = r
instance Monoid (Last a)
where
mempty = Last Nothing
getDual :: !(Dual .a) -> .a
getDual (Dual x) = x
......
definition module Data.Tuple
from Data.Functor import class Functor
from Data.Monoid import class Semigroup, class Monoid
from Data.Foldable import class Foldable
from Data.Traversable import class Traversable
from Data.Bifunctor import class Bifunctor
tuple :: .a .b -> .(.a,.b)
tuple3 :: .a .b .c -> .(.a,.b,.c)
appFst :: .(.a -> .c) !(.a,.b) -> (.c,.b)
appSnd :: .(.b -> .c) !(.a,.b) -> (.a,.c)
appFst3 :: .(.a -> .d) !(.a,.b,.c) -> (.d,.b,.c)
appSnd3 :: .(.b -> .d) !(.a,.b,.c) -> (.a,.d,.c)
appThd3 :: .(.c -> .d) !(.a,.b,.c) -> (.a,.b,.d)
swap :: !.(.a, .b) -> .(.b, .a)
instance Functor ((,) a)
instance Functor ((,,) a b)
instance Functor ((,,,) a b c)
instance Functor ((,,,,) a b c d)
instance Functor ((,,,,,) a b c d e)
instance Semigroup (a, b) | Semigroup a & Semigroup b
instance Semigroup (a, b, c) | Semigroup a & Semigroup b & Semigroup c
instance Semigroup (a, b, c, d) | Semigroup a & Semigroup b & Semigroup c & Semigroup d
instance Semigroup (a, b, c, d, e) | Semigroup a & Semigroup b & Semigroup c & Semigroup d & Semigroup e
instance Monoid (a, b) | Monoid a & Monoid b
instance Monoid (a, b, c) | Monoid a & Monoid b & Monoid c
instance Monoid (a, b, c, d) | Monoid a & Monoid b & Monoid c & Monoid d
instance Monoid (a, b, c, d, e) | Monoid a & Monoid b & Monoid c & Monoid d & Monoid e
instance Foldable ((,) a)
instance Traversable ((,) a)
instance Bifunctor (,)
instance Bifunctor ((,,) x)
instance Bifunctor ((,,,) x y)
instance Bifunctor ((,,,,) x y z)
definition module Data.Tuple
from Control.Monad import class pure, class <*>, class Applicative
from Data.Functor import class Functor
from Data.Monoid import class Semigroup, class Monoid
from Data.Foldable import class Foldable
from Data.Traversable import class Traversable
from Data.Bifunctor import class Bifunctor
tuple :: .a .b -> .(.a,.b)
tuple3 :: .a .b .c -> .(.a,.b,.c)
appFst :: .(.a -> .c) !(.a,.b) -> (.c,.b)
appSnd :: .(.b -> .c) !(.a,.b) -> (.a,.c)
appFst3 :: .(.a -> .d) !(.a,.b,.c) -> (.d,.b,.c)
appSnd3 :: .(.b -> .d) !(.a,.b,.c) -> (.a,.d,.c)
appThd3 :: .(.c -> .d) !(.a,.b,.c) -> (.a,.b,.d)
swap :: !.(.a, .b) -> .(.b, .a)
instance Functor ((,) a)
instance Functor ((,,) a b)
instance Functor ((,,,) a b c)
instance Functor ((,,,,) a b c d)
instance Functor ((,,,,,) a b c d e)
instance Semigroup (a, b) | Semigroup a & Semigroup b
where
mappend :: !(a,b) !(a,b) -> (a,b) | Semigroup a & Semigroup b
instance Semigroup (a, b, c) | Semigroup a & Semigroup b & Semigroup c
where
mappend :: !(a,b,c) !(a,b,c) -> (a,b,c) | Semigroup a & Semigroup b & Semigroup c
instance Semigroup (a, b, c, d) | Semigroup a & Semigroup b & Semigroup c & Semigroup d
where
mappend :: !(a,b,c,d) !(a,b,c,d) -> (a,b,c,d) | Semigroup a & Semigroup b & Semigroup c & Semigroup d
instance Semigroup (a, b, c, d, e) | Semigroup a & Semigroup b & Semigroup c & Semigroup d & Semigroup e
where
mappend :: !(a,b,c,d,e) !(a,b,c,d,e) -> (a,b,c,d,e) | Semigroup a & Semigroup b & Semigroup c & Semigroup d & Semigroup e
instance Monoid (a, b) | Monoid a & Monoid b
instance Monoid (a, b, c) | Monoid a & Monoid b & Monoid c
instance Monoid (a, b, c, d) | Monoid a & Monoid b & Monoid c & Monoid d
instance Monoid (a, b, c, d, e) | Monoid a & Monoid b & Monoid c & Monoid d & Monoid e
instance Foldable ((,) a)
where
foldMap :: !(a -> b) !(c,a) -> b | Monoid b
foldr :: !(a -> .b -> .b) .b !(c,a) -> .b
instance Traversable ((,) a)
where
traverse :: !(a -> b c) !(d,a) -> b (d,c) | Applicative b
instance Bifunctor (,)
instance Bifunctor ((,,) x)
instance Bifunctor ((,,,) x y)
instance Bifunctor ((,,,,) x y z)
......@@ -56,6 +56,7 @@ where
instance Semigroup (a, b) | Semigroup a & Semigroup b
where
mappend :: !(a,b) !(a,b) -> (a,b) | Semigroup a & Semigroup b
mappend (a1, b1) (a2, b2) = (mappend a1 a2, mappend b1 b2)
instance Monoid (a, b) | Monoid a & Monoid b
......@@ -64,6 +65,7 @@ where
instance Semigroup (a, b, c) | Semigroup a & Semigroup b & Semigroup c
where
mappend :: !(a,b,c) !(a,b,c) -> (a,b,c) | Semigroup a & Semigroup b & Semigroup c
mappend (a1, b1, c1) (a2, b2, c2) = (mappend a1 a2, mappend b1 b2, mappend c1 c2)
instance Monoid (a, b, c) | Monoid a & Monoid b & Monoid c
......@@ -72,6 +74,7 @@ where
instance Semigroup (a, b, c, d) | Semigroup a & Semigroup b & Semigroup c & Semigroup d
where
mappend :: !(a,b,c,d) !(a,b,c,d) -> (a,b,c,d) | Semigroup a & Semigroup b & Semigroup c & Semigroup d
mappend (a1, b1, c1, d1) (a2, b2, c2, d2) = (mappend a1 a2, mappend b1 b2, mappend c1 c2, mappend d1 d2)
instance Monoid (a, b, c, d) | Monoid a & Monoid b & Monoid c & Monoid d
......@@ -80,6 +83,7 @@ where
instance Semigroup (a, b, c, d, e) | Semigroup a & Semigroup b & Semigroup c & Semigroup d & Semigroup e
where
mappend :: !(a,b,c,d,e) !(a,b,c,d,e) -> (a,b,c,d,e) | Semigroup a & Semigroup b & Semigroup c & Semigroup d & Semigroup e