haskell - How to make Vect n Int an instance of Monoid -
haskell - How to make Vect n Int an instance of Monoid - in idris, vect n a datatype representing vector of n length containing items of type a. imagine have function: foo : int -> vect 4 int foo n = [n-1, n, n+1, n*4] the body of function not important, returns vector of 4 ints. now, want utilize function concatmap follows: bar : vect n int -> vect (4*n) int bar vals = concatmap foo vals bar function takes int vector of length n , returns ones of length 4*n. the type signature of concatmap is: prelude.foldable.concatmap : foldable t => monoid m => (a -> m) -> t -> m and hence if seek compile bar, error: when elaborating right hand side of bar: can't resolve type class monoid (vect (plus n (plus n (plus n (plus n 0)))) int) this means vect n int isn't instance of monoid. create instance of monoid, need implement: prelude.algebra.neutral : monoid => unfortunately i'm not sure how this. list implements mon...