A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://agda.github.io/agda-stdlib/master/Data.Vec.Effectful.Foldable.html below:

Data.Vec.Effectful.Foldable

Data.Vec.Effectful.Foldable
------------------------------------------------------------------------
-- The Agda standard library
--
-- Vec is Foldable
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}

module Data.Vec.Effectful.Foldable where

open import Algebra.Bundles.Raw using (RawMonoid)
open import Data.Nat.Base using ()
open import Data.Vec.Base using (Vec; []; _∷_; foldr′; foldl′; toList)
open import Effect.Foldable using (RawFoldableWithDefaults; RawFoldable)
open import Function.Base using (id)
open import Level using (Level)

private
  variable
    a c  : Level
    A : Set a
    n : 

------------------------------------------------------------------------
-- Root implementation

module _ (M : RawMonoid c ) where

  open RawMonoid M

  foldMap : (A  Carrier)  Vec A n  Carrier
  foldMap f []       = ε
  foldMap f (x  xs) = f x  foldMap f xs

------------------------------------------------------------------------
-- Basic implementation using supplied defaults

foldableWithDefaults : RawFoldableWithDefaults {a}  A  Vec A n)
foldableWithDefaults = record { foldMap = λ M  foldMap M }

------------------------------------------------------------------------
-- Specialised version using optimised implementations

foldable : RawFoldable {a}  A  Vec A n)
foldable = record
  { foldMap = λ M  foldMap M
  ; foldr = foldr′
  ; foldl = foldl′
  ; toList = toList
  }


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4