Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new module Effect.Functor.Naperian #2004

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,12 @@ New modules
```
Algebra.Properties.KleeneAlgebra
```


* New module for Naperian functor
```
Effect.Functor.Naperian
```

* Relations on indexed sets
```
Function.Indexed.Bundles
Expand Down Expand Up @@ -2879,7 +2884,18 @@ Other minor changes
foldr-map : foldr f x (map g xs) ≡ foldr (g -⟨ f ∣) x xs
foldl-map : foldl f x (map g xs) ≡ foldl (∣ f ⟩- g) x xs
```


* Added new lemmas in `Data.List.Propreties`:
```
take-[] : ∀ m → take m [] ≡ []
drop-[] : ∀ m → drop m [] ≡ []
```
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
* Added new definitions to `Effect.Functor.Naperian`
```
record RawNaperian (RF : RawFunctor F) : Set (suc (b ⊔ d) ⊔ c)
record Naperian (RF : RawFunctor F) : Set (suc (b ⊔ d) ⊔ c)
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
```

NonZero/Positive/Negative changes
---------------------------------

Expand Down
43 changes: 43 additions & 0 deletions src/Effect/Functor/Naperian.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Naperian functor
--
-- This file contains definitions of Naperian introduced by Jeremy Gibbons
-- in the book APLicative Programming with Naperian Functors.
-- https://link.springer.com/chapter/10.1007/978-3-662-54434-1_21
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
------------------------------------------------------------------------

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

module Effect.Functor.Naperian where

open import Effect.Functor using (RawFunctor)
open import Level using (Level; suc; _⊔_)
open import Relation.Binary.PropositionalEquality.Core using (_≡_)

private
variable
b c : Level
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved


-- " Functor f is Naperian if there is a type p of ‘positions’ such that fa≃p→a;
-- then p behaves a little like a logarithm of f
-- in particular, if f and g are both Naperian, then Log(f×g)≃Logf+Logg and Log(f.g) ≃ Log f × Log g"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it would be great if your PR could come good on this promise by exhibiting the constructions?

-- APLicative Programming with Naperian Functors. Jeremy Gibbons.

-- RawNaperian contains just the functions, not the proofs
record RawNaperian {F : Set b → Set c} (d : Level) (RF : RawFunctor F) : Set (suc (b ⊔ d) ⊔ c) where
field
Log : Set d
index : ∀ {A} → F A → (Log → A)
tabulate : ∀ {A} → (Log → A) → F A
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved

-- Full Naperian has the coherence conditions too. Propositional version (hard to work with).
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved
record Naperian {F : Set b → Set c} (d : Level) (RF : RawFunctor F) : Set (suc (b ⊔ d) ⊔ c) where
field
rawNaperian : RawNaperian d RF
open RawNaperian rawNaperian public
field
tabulate-index : ∀ {A} → (fa : F A) → tabulate (index fa) ≡ fa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So: here the induced Setoid relation on F A?

index-tabulate : ∀ {A} → (f : Log → A) → ((l : Log) → index (tabulate f) l ≡ f l)
JacquesCarette marked this conversation as resolved.
Show resolved Hide resolved