Skip to content

`stimes` adds extra power to Semigroup

ghci> stimes 0 (undefined :: [_])
[]

ghci> stimes 0 undefined
()

makes it seem like stimes 0 has some knowledge about mempty from Monoid but it has the following type

stimes 0 :: Semigroup a => a -> a

Desired behaviour? Given that type (assuming it only has the power of <>) I would have assumed this behaviour

ghci> data L a = N | C a (L a) deriving Show
ghci> instance Semigroup (L a) where (<>) = undefined
ghci| 
ghci> stimes 0 (undefined :: L _)
*** Exception: stimes: positive multiplier expected
Edited by Icelandjack
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information