Skip to content

Commit

Permalink
[ base ] Add semigroup and monoid instances for Vect
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden authored and gallais committed Aug 13, 2021
1 parent c1ebc05 commit c29dc73
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libs/base/Data/Vect.idr
Expand Up @@ -866,6 +866,18 @@ implementation Traversable (Vect k) where
traverse f [] = pure []
traverse f (x :: xs) = [| f x :: traverse f xs |]

--------------------------------------------------------------------------------
-- Semigroup/Monoid
--------------------------------------------------------------------------------

public export
Semigroup a => Semigroup (Vect k a) where
(<+>) = zipWith (<+>)

public export
{k : Nat} -> Monoid a => Monoid (Vect k a) where
neutral = replicate k neutral

--------------------------------------------------------------------------------
-- Show
--------------------------------------------------------------------------------
Expand Down

0 comments on commit c29dc73

Please sign in to comment.