Skip to content

Commit c29dc73

Browse files
buzdengallais
authored andcommitted
[ base ] Add semigroup and monoid instances for Vect
1 parent c1ebc05 commit c29dc73

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libs/base/Data/Vect.idr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,18 @@ implementation Traversable (Vect k) where
866866
traverse f [] = pure []
867867
traverse f (x :: xs) = [| f x :: traverse f xs |]
868868

869+
--------------------------------------------------------------------------------
870+
-- Semigroup/Monoid
871+
--------------------------------------------------------------------------------
872+
873+
public export
874+
Semigroup a => Semigroup (Vect k a) where
875+
(<+>) = zipWith (<+>)
876+
877+
public export
878+
{k : Nat} -> Monoid a => Monoid (Vect k a) where
879+
neutral = replicate k neutral
880+
869881
--------------------------------------------------------------------------------
870882
-- Show
871883
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)