| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- An effectful view of Stream |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --sized-types #-} |
| 8 |
|
| 9 |
module Codata.Sized.Stream.Effectful where |
| 10 |
|
| 11 |
open import Data.Product.Base using (<_,_>) |
| 12 |
open import Codata.Sized.Stream using |
| 13 |
(Stream; _∷_; _++_; _⁺++_; map; repeat; ap; head; unfold; tail) |
| 14 |
open import Effect.Functor using (RawFunctor) |
| 15 |
open import Effect.Applicative using (RawApplicative) |
| 16 |
open import Effect.Comonad using (RawComonad) |
| 17 |
open import Function.Base using (_∘′_) |
| 18 |
|
| 19 |
functor : ∀ {ℓ i} → RawFunctor {ℓ} (λ A → Stream A i) |
| 20 |
functor = record { _<$>_ = λ f → map f } |
| 21 |
|
| 22 |
applicative : ∀ {ℓ i} → RawApplicative {ℓ} (λ A → Stream A i) |
| 23 |
applicative = record |
| 24 |
{ rawFunctor = functor |
| 25 |
; pure = repeat |
| 26 |
; _<*>_ = ap |
| 27 |
} |
| 28 |
|
| 29 |
comonad : ∀ {ℓ} → RawComonad {ℓ} (λ A → Stream A _) |
| 30 |
comonad = record |
| 31 |
{ extract = head |
| 32 |
; extend = unfold ∘′ < tail ,_> |
| 33 |
} |