├── .ctags ├── .gitignore ├── .travis.yml ├── .yamllint ├── Data └── Functor │ ├── Foldable.idr │ └── Foldable │ ├── Exotic.idr │ ├── Instances.idr │ └── Mod.idr ├── Justfile ├── LICENSE ├── README.md ├── TODO.md ├── Test └── Spec.idr ├── docs ├── IdrisDoc ├── docs │ ├── Control.Comonad.html │ ├── Control.Monad.Free.html │ ├── Control.Monad.Identity.html │ ├── Data.Functor.Foldable.Exotic.html │ ├── Data.Functor.Foldable.Instances.html │ ├── Data.Functor.Foldable.Mod.html │ ├── Data.Profunctor.Comonad.Cofree.html │ ├── Decidable.Equality.html │ ├── FFI.html │ ├── FFI_C.html │ ├── ForeignEnv.html │ ├── Language.Reflection.Elab.html │ ├── Language.Reflection.html │ ├── Prelude.Algebra.html │ ├── Prelude.Basics.html │ ├── Prelude.Bool.html │ ├── Prelude.Either.html │ ├── Prelude.File.html │ ├── Prelude.Foldable.html │ ├── Prelude.Functor.html │ ├── Prelude.Interfaces.html │ ├── Prelude.List.html │ ├── Prelude.Maybe.html │ ├── Prelude.Monad.html │ ├── Prelude.Nat.html │ ├── Prelude.Show.html │ ├── Prelude.Stream.html │ └── [builtins].html ├── index.html └── styles.css ├── elba.toml ├── recursion_schemes.ipkg └── test.ipkg /.ctags: -------------------------------------------------------------------------------- 1 | --langdef=Idris 2 | --langmap=Idris:.idr 3 | --regex-Idris=/^ *([[:lower:]][[:alnum:]_]+)[[:blank:]]*:[^:].*->.*/\1/f,function,functions/ 4 | --regex-Idris=/^ *([[:lower:]][[:alnum:]_]+)[[:blank:]]*:[^:][^-]+$/\1/c,constant,constants/ 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | tags 3 | *.ibc 4 | elba.lock 5 | target 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | sudo: false 3 | language: python 4 | cache: 5 | directories: 6 | - $HOME/.cabal 7 | - $HOME/.ghc 8 | addons: 9 | apt: 10 | sources: 11 | - hvr-ghc 12 | packages: 13 | - libgmp3-dev 14 | - ghc-8.4.3 15 | - cabal-install-2.2 16 | 17 | install: 18 | - rm -rf $HOME/.cabal 19 | - export PATH=/opt/ghc/$GHCVER/bin:$PATH 20 | - export PATH=$HOME/.cabal/bin:$PATH 21 | - cabal update 22 | - mkdir -p $HOME/.cabal/store/ghc-8.4.3/package.db 23 | - travis_wait 40 cabal new-install idris 24 | - git clone https://github.com/pheymann/specdris 25 | - git clone https://github.com/vmchale/comonad 26 | - git clone https://github.com/idris-hackers/idris-free.git 27 | - cd specdris/ 28 | - idris --install specdris.ipkg 29 | - cd ../comonad/ 30 | - idris --install comonad.ipkg 31 | - cd ../idris-free 32 | - idris --install idris-free.ipkg 33 | 34 | script: 35 | - cd ../ 36 | - idris --testpkg test.ipkg 37 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | rules: 4 | braces: 5 | min-spaces-inside: 0 6 | max-spaces-inside: 0 7 | min-spaces-inside-empty: -1 8 | max-spaces-inside-empty: -1 9 | brackets: 10 | min-spaces-inside: 0 11 | max-spaces-inside: 0 12 | min-spaces-inside-empty: -1 13 | max-spaces-inside-empty: -1 14 | colons: 15 | max-spaces-before: 0 16 | max-spaces-after: 1 17 | commas: 18 | max-spaces-before: 0 19 | min-spaces-after: 1 20 | max-spaces-after: 1 21 | comments: 22 | level: warning 23 | require-starting-space: true 24 | min-spaces-from-content: 2 25 | comments-indentation: 26 | level: warning 27 | document-end: disable 28 | document-start: 29 | level: warning 30 | present: true 31 | empty-lines: 32 | max: 2 33 | max-start: 0 34 | max-end: 0 35 | hyphens: 36 | max-spaces-after: 1 37 | indentation: 38 | spaces: consistent 39 | indent-sequences: false 40 | check-multi-line-strings: false 41 | key-duplicates: enable 42 | line-length: disable 43 | new-line-at-end-of-file: enable 44 | new-lines: 45 | type: unix 46 | trailing-spaces: enable 47 | truthy: disable 48 | -------------------------------------------------------------------------------- /Data/Functor/Foldable.idr: -------------------------------------------------------------------------------- 1 | ||| Convenience module that re-exports everything. 2 | module Data.Functor.Foldable 3 | 4 | import public Data.Functor.Foldable.Mod 5 | import public Data.Functor.Foldable.Exotic 6 | import public Data.Functor.Foldable.Instances 7 | -------------------------------------------------------------------------------- /Data/Functor/Foldable/Exotic.idr: -------------------------------------------------------------------------------- 1 | module Data.Functor.Foldable.Exotic 2 | 3 | import Control.Arrow 4 | import Control.Monad.Identity 5 | import Control.Comonad 6 | import Control.Comonad.Cofree 7 | import Data.Functor.Foldable.Mod 8 | import Data.Functor.Foldable.Instances 9 | 10 | %access public export 11 | 12 | infixl 9 .* 13 | 14 | (.*) : (c -> d) -> (a -> b -> c) -> (a -> b -> d) 15 | (.*) f g x y = f (g x y) 16 | 17 | ||| Gibbons' metamorphism. Tear down a structure, transform it, and then build up a new structure 18 | meta : (Functor f, Corecursive f t', Recursive g t) => (a -> f a) -> (b -> a) -> (g b -> b) -> t -> t' 19 | meta f e g = ana f . e . cata g 20 | 21 | ||| Erwig's metamorphism. Essentially a hylomorphism with a natural 22 | ||| transformation in between. This allows us to use more than one functor in a 23 | ||| hylomorphism. 24 | hyloPro : (Functor f, Functor g) => (f a -> a) -> ({c:_} -> g c -> f c) -> (b -> g b) -> b -> a 25 | hyloPro h e k = g 26 | where g x = h . e . map g . k $ x 27 | 28 | ||| A dynamorphism builds up with an anamorphism and tears down with a 29 | ||| histomorphism. Useful for lexical scoping. 30 | dynaPro : (Functor f, Functor g) => (f (Cofree f a) -> a) -> ({c:_} -> g c -> f c) -> (b -> g b) -> b -> a 31 | dynaPro phi eta psi = ghylo distHisto distAna phi (eta . map Id . psi) 32 | 33 | ||| A dynamorphism without a natural transformation in between. 34 | dyna : (Functor f) => (f (Cofree f a) -> a) -> (b -> f b) -> b -> a 35 | dyna phi = dynaPro phi id 36 | 37 | ||| Mendler's catamorphism 38 | mcata : ({y : _} -> ((y -> c) -> f y -> c)) -> Fix f -> c 39 | mcata psi = psi (mcata psi) . unfix 40 | 41 | --Basically, this forms an F-algebra from a loopkup functoin plus a function that gives us the lookup function 42 | ||| Mendler's histomorphism 43 | mhisto : ({y : _} -> ((y -> c) -> (y -> f y) -> f y -> c)) -> Fix f -> c 44 | mhisto psi = psi (mhisto psi) unfix . unfix 45 | 46 | ||| Elgot algebra (see [this paper](https://arxiv.org/abs/cs/0609040)) 47 | elgot : Functor f => (f a -> a) -> (b -> Either a (f b)) -> b -> a 48 | elgot phi psi = h where h = (id `either` phi . map h) . psi 49 | 50 | ||| Anamorphism that allows shortcuts. 51 | micro : (Functor f, Corecursive f a) => (b -> Either a (f b)) -> b -> a 52 | micro = elgot embed 53 | 54 | ||| Elgot coalgebra 55 | coelgot : Functor f => ((a, f b) -> b) -> (a -> f a) -> a -> b 56 | coelgot phi psi = h where h = phi . (\x => (x, (map h . psi) x)) 57 | -------------------------------------------------------------------------------- /Data/Functor/Foldable/Instances.idr: -------------------------------------------------------------------------------- 1 | -- ------------------------------------- [ Data.Functor.Foldable.Instances.idr ] 2 | -- Module : Data.Functor.Foldable.Internal.Instances 3 | -- Description : Instances of 'Recursive' and 'Corecursive' for various 4 | -- things. 5 | -- --------------------------------------------------------------------- [ EOH ] 6 | module Data.Functor.Foldable.Instances 7 | 8 | import Control.Monad.Free 9 | import Data.Functor.Foldable.Mod 10 | 11 | %access public export 12 | 13 | implementation Base Nat Maybe where 14 | 15 | implementation Recursive Maybe Nat where 16 | project Z = Nothing 17 | project (S a) = Just a 18 | 19 | implementation Corecursive Maybe Nat where 20 | embed Nothing = Z 21 | embed (Just a) = S a 22 | 23 | ||| Fix-point data type for exotic recursion schemes of various kinds 24 | data Fix : (Type -> Type) -> Type where 25 | Fx : f (Fix f) -> Fix f 26 | 27 | ||| Nu fix-point functor for coinduction 28 | codata Nu : (f : Type -> Type) -> Type -> Type where 29 | NuF : ((a -> f a) -> a) -> b -> Nu f b 30 | 31 | ||| Mu fix-point functor for induction 32 | data Mu : (Type -> Type) -> Type where 33 | MuF : ({a : Type} -> (a -> f a) -> a) -> Mu f 34 | 35 | implementation Functor (Nu f) where 36 | map g (NuF h a) = NuF h (g a) 37 | 38 | implementation Base t (Nu f) where 39 | 40 | implementation Base (Fix t) f where 41 | 42 | implementation Base (Mu f) f where 43 | 44 | ||| Create a fix-point with a functor 45 | fix : f (Fix f) -> Fix f 46 | fix = Fx 47 | 48 | ||| Unfix a 'Fix f' 49 | unfix : Fix f -> f (Fix f) 50 | unfix (Fx x) = x 51 | 52 | data ListF : Type -> Type -> Type where 53 | NilF : ListF _ _ 54 | Cons : a -> b -> ListF a b 55 | 56 | data StreamF : Type -> Type -> Type where 57 | Pipe : a -> b -> StreamF a b 58 | 59 | implementation Functor (StreamF a) where 60 | map f (Pipe a b) = Pipe a (f b) 61 | 62 | implementation Functor (ListF a) where 63 | map _ NilF = NilF 64 | map f (Cons a b) = Cons a (f b) 65 | 66 | implementation Base b (ListF a) where 67 | 68 | implementation Base b (StreamF a) where 69 | 70 | ||| Lambek's lemma assures us this function always exists. 71 | lambek : (Recursive f t, Corecursive f t) => (t -> f t) 72 | lambek = cata (map embed) 73 | 74 | ||| The dual of Lambek's lemma. 75 | colambek : (Recursive f t, Corecursive f t) => (f t -> t) 76 | colambek = ana (map project) 77 | 78 | implementation Recursive (StreamF a) (Stream a) where 79 | project (x::xs) = Pipe x xs 80 | 81 | implementation Corecursive (StreamF a) (Stream a) where 82 | embed (Pipe x xs) = x::xs 83 | 84 | implementation Recursive (ListF a) (List a) where 85 | project [] = NilF 86 | project (x::xs) = Cons x xs 87 | 88 | implementation Corecursive (ListF a) (List a) where 89 | embed NilF = [] 90 | embed (Cons x xs) = x::xs 91 | -------------------------------------------------------------------------------- /Data/Functor/Foldable/Mod.idr: -------------------------------------------------------------------------------- 1 | ||| Module containing the main typeclasses and recursion schemes on them. 2 | module Data.Functor.Foldable.Mod 3 | 4 | import Control.Monad.Identity 5 | import Control.Monad.Free 6 | import Control.Comonad 7 | import Control.Comonad.Cofree 8 | 9 | %access public export 10 | 11 | ||| This is an interface which does nothing interesting, but it functions as a 12 | ||| way of saying "f is a base functor with underlying type t" 13 | interface Base t (f : Type -> Type) where 14 | 15 | ||| Interface for corecursive data types. Corecursive types correspond to 16 | ||| anamorphisms. 17 | interface (Functor f, Base t f) => Corecursive (f : Type -> Type) (t : Type) where 18 | embed : f t -> t 19 | 20 | ||| Recursive types correspond to catamorphisms. 21 | interface (Functor f, Base t f) => Recursive (f : Type -> Type) (t : Type) where 22 | project : t -> f t 23 | 24 | ||| Anamorphism, meant to build up a structure recursively. 25 | ana : (Corecursive f t) => (a -> f a) -> a -> t 26 | ana g = a' 27 | where a' x = embed . map a' . g $ x 28 | 29 | ||| Postpromorphism. Unfold a structure, applying a natural transformation along the way. 30 | postpro : (Recursive f t, Corecursive f t) => (f t -> f t) -> (a -> f a) -> a -> t 31 | postpro e g = a' 32 | where a' x = embed . map (ana (e . project) . a') . g $ x 33 | 34 | ||| Generalized Anamorphism 35 | ||| @ k A distributive law 36 | ||| @ g A (f . m)-coalgebra 37 | gana : (Corecursive f t, Monad m) => (k : {b : _} -> m (f b) -> f (m b)) -> (g : a -> f (m a)) -> a -> t 38 | gana k g = (gan k g) . pure . g 39 | where gan : (Corecursive f t, Monad m) => (k : {b : _} -> m (f b) -> f (m b)) -> (g : a -> f (m a)) -> m (f (m a)) -> t 40 | gan k g x = embed . map ((gan k g) . map g . join) . k $ x 41 | 42 | ||| Generalized catamorphism 43 | ||| @ k A distributive law 44 | ||| @ g A (f . w)-algebra 45 | gcata : (Recursive f t, Comonad w) => (k : {b:_} -> f (w b) -> w (f b)) -> (g : f (w a) -> a) -> t -> a 46 | gcata k g = g . extract . (gcat k g) 47 | where gcat : (Recursive f t, Comonad w) => (k : {b:_} -> f (w b) -> w (f b)) -> (g : f (w a) -> a) -> t -> w (f (w a)) 48 | gcat k g x = k . map (duplicate . map g . (gcat k g)) . project $ x 49 | 50 | ||| Generalized hylomorphism 51 | ||| @ k A distributive law on f 52 | ||| @ l A distributive law on l 53 | ||| @ f' A (f . w)-algebra 54 | ||| @ g' A (f . m)-coalgebra 55 | ghylo : (Functor f, Comonad w, Monad m) => 56 | (k : {b:_} -> f (w b) -> w (f b)) -> 57 | (l : {c:_} -> m (f c) -> f (m c)) -> 58 | (f' : f (w b) -> b) -> 59 | (g' : a -> f (m a)) -> 60 | a -> b 61 | ghylo k l f' g' = extract . (gh k l f' g') . pure where 62 | gh : (Functor f, Comonad w, Monad m) => (k : {d:_} -> f (w d) -> w (f d)) -> (l : {c:_} -> m (f c) -> f (m c)) -> (f' : f (w b) -> b) -> (g' : a -> f (m a)) -> m a -> w b 63 | gh k l f' g' x = map f' . k . map (duplicate . (gh k l f' g') . join) . l . map g' $ x 64 | 65 | ||| Distributive law for catamorphisms 66 | distCata : Functor f => f (Identity a) -> Identity (f a) 67 | distCata = Id . map runIdentity 68 | 69 | ||| Distributive law for anamorphisms. 70 | distAna : Functor f => Identity (f a) -> f (Identity a) 71 | distAna = map Id . runIdentity 72 | 73 | ||| Distributive law for futumorphisms. 74 | distFutu : (Functor f) => Free f (f a) -> f (Free f a) 75 | distFutu (Pure fa) = Pure <$> fa 76 | distFutu (Bind as) = Bind <$> (distFutu <$> as) 77 | 78 | ||| Futumorphism 79 | futu : (Corecursive f t) => (a -> f (Free f a)) -> a -> t 80 | futu = gana distFutu 81 | 82 | ||| Distributive law for histomorphisms 83 | distHisto : (Functor f) => f (Cofree f a) -> Cofree f (f a) 84 | distHisto = unfold g where 85 | g as = (extract <$> as, unwrap <$> as) 86 | 87 | ||| Histomorphism 88 | histo : (Recursive f t) => (f (Cofree f a) -> a) -> t -> a 89 | histo = gcata distHisto 90 | 91 | ||| Chronomorphism 92 | chrono : Functor f => (f (Cofree f b) -> b) -> (a -> f (Free f a)) -> a -> b 93 | chrono = ghylo distHisto distFutu 94 | 95 | ||| Catamorphism. Folds a structure. (see [here](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.41.125&rep=rep1&type=pdf)) 96 | cata : (Recursive f t) => (f a -> a) -> t -> a 97 | cata f = c 98 | where c x = f . map c . project $ x 99 | 100 | ||| Prepromorphism. Fold a structure while applying a natural transformation at each step. 101 | prepro : (Recursive f t, Corecursive f t) => (f t -> f t) -> (f a -> a) -> t -> a 102 | prepro e f = c 103 | where c x = f . map (c . (cata (embed . e))) . project $ x 104 | 105 | ||| Catamorphism interweaving two data types. 106 | dicata : (Recursive f b, Recursive f a) => (f (b, a) -> b) -> (f (b, a) -> a) -> b -> a 107 | dicata f g = snd . cata (\x => (f x, g x)) 108 | 109 | ||| Mutumorphism 110 | mutu : (Recursive f t) => (f (a, a) -> a) -> (f (a, a) -> a) -> t -> a 111 | mutu f g x = g . map (\x => (mutu g f x, mutu f g x)) . project $ x 112 | 113 | ||| Zygomorphism (see [here](http://www.iis.sinica.edu.tw/~scm/pub/mds.pdf) for a neat example) 114 | zygo : (Recursive f t) => (f b -> b) -> (f (b, a) -> a) -> t -> a 115 | zygo f g = snd . cata (\x => (f $ map fst x, g x)) 116 | 117 | ||| Paramorphism 118 | para : (Recursive f t, Corecursive f t) => (f (t, a) -> a) -> t -> a 119 | para f = snd . cata (\x => (embed $ map fst x, f x)) 120 | 121 | ||| Hylomorphism; equivalent to a catamorphism and an anamorphism taken together. 122 | hylo : Functor f => (f b -> b) -> (a -> f a) -> a -> b 123 | hylo f g = h 124 | where h x = f . map h . g $ x 125 | -------------------------------------------------------------------------------- /Justfile: -------------------------------------------------------------------------------- 1 | clean: 2 | sn c . 3 | rm -f tags 4 | 5 | build: 6 | idris --build recursion_schemes.ipkg 7 | 8 | test: 9 | idris --testpkg test.ipkg 10 | 11 | update-docs: 12 | sn c . 13 | rm -rf docs 14 | idris --mkdoc recursion_schemes.ipkg 15 | mv recursion_schemes_doc/ docs/ 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Vanessa McHale (c) 2017 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # recursion_schemes 2 | 3 | [![Build Status](https://travis-ci.org/vmchale/recursion_schemes.svg?branch=master)](https://travis-ci.org/vmchale/recursion\_schemes) 4 | 5 | This is a library providing recursion schemes for Idris. It it is loosely based 6 | on Edward Kmett's [Haskell 7 | library](https://hackage.haskell.org/package/recursion-schemes). 8 | 9 | ## Installation 10 | 11 | First, install [idris-free](https://github.com/idris-hackers/idris-free), 12 | [comonad](https://github.com/vmchale/comonad) and [composition](https://github.com/vmchale/composition). Then: 13 | 14 | ``` 15 | idris --install recursion_schemes.ipkg 16 | ``` 17 | 18 | To run the tests, install [specdris](https://github.com/pheymann/specdris). 19 | Then: 20 | 21 | ``` 22 | idris --testpkg test.ipkg 23 | ``` 24 | 25 | ## Use 26 | 27 | The classic paper [Functional programming with bananas, lenses, envelopes and 28 | barbed wire](https://link.springer.com/chapter/10.1007/3540543961_7) is the 29 | inspiration behind the Haskell library and is the standard reference on the 30 | topic. You may also find [Law and Order in 31 | Algorithmics](https://pdfs.semanticscholar.org/7ca8/326eb63f32502c0fc2324b6217a7bc7e8af4.pdf) 32 | to be of use. 33 | 34 | ### Examples 35 | 36 | In the `Test.Spec` module there are several examples, including a catamorphism, 37 | a zygomorphism, a mutumorphism, an Elgot algebra, a paramorphism, a 38 | dynamorphism, and a hylomorphism. 39 | 40 | ### Documentation 41 | 42 | You can find documentation 43 | [here](https://vmchale.github.io/recursion_schemes/index.html). 44 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # morphisms 2 | - [x] catamorphism 3 | - [x] paramorphism 4 | - [x] futumorphism 5 | - [x] mutumorphism 6 | - [x] zygomorphism 7 | - [x] prepromorphism 8 | - [x] generalized anamorphism 9 | - [x] histomorphism 10 | - [x] dynamorphism 11 | - [x] chronomorphism 12 | - [ ] synchromorphism (see this paper: 13 | https://www.fernuni-hagen.de/imperia/md/content/fakultaetfuermathematikundinformatik/forschung/berichte/bericht_266.pdf) 14 | - [x] anamorphism 15 | - [x] apomorphism 16 | - [x] postpromorphism 17 | - [x] hylomorphism 18 | - [ ] monadic versions 19 | # nice stuff 20 | - [x] fancy type-level chicanery 21 | - [ ] Mu, Nu fix-point functors 22 | # tests 23 | - [x] zygomorphism 24 | - [x] elgot algebra 25 | - [x] Collatz sequence? 26 | - [x] hylomorphism 27 | - [x] catamorphism 28 | # proofs 29 | - [ ] cata/ana/hylo laws 30 | - [ ] termination proofs? 31 | # ci 32 | - [ ] make nix expression fetch/install dependencies? 33 | - [ ] script to bump dependencies to newest commit & attendant sha hash 34 | -------------------------------------------------------------------------------- /Test/Spec.idr: -------------------------------------------------------------------------------- 1 | module Test.Spec 2 | 3 | import Specdris.Spec 4 | import Data.Functor.Foldable 5 | import Data.Vect 6 | import Control.Comonad.Cofree 7 | 8 | -- FIXME morphisms with constraints? particularly re: symmteries 9 | -- "safe" compilation using this? 10 | -- particularly discrete pseudo-hamiltonian dynamics 11 | -- oh man finite symplectic geometry 12 | 13 | -- TODO computation of pi from http://www.cs.ox.ac.uk/jeremy.gibbons/publications/metamorphisms-mpc.pdf 14 | 15 | naturals : Nat -> ListF Nat Nat 16 | naturals Z = NilF 17 | naturals (S n) = Cons (n + 1) n 18 | 19 | -- This is also an instructive use of cofree comonads! 20 | -- Do note that it indexes starting at 0. 21 | catalan : Nat -> Nat 22 | catalan = dyna coalgebra naturals 23 | where 24 | coalgebra : ListF Nat (Cofree (ListF Nat) Nat) -> Nat 25 | coalgebra NilF = 1 26 | coalgebra (Cons n table) = sum (Prelude.List.zipWith (*) xs (reverse xs)) 27 | where 28 | xs = take n table 29 | take : Nat -> (Cofree (ListF Nat) Nat) -> List Nat 30 | take Z _ = [] 31 | take (S n) (Co a NilF) = [a] 32 | take (S n) (Co a (Cons v as)) = a :: take n as 33 | 34 | roundedSqrt : Nat -> Nat 35 | roundedSqrt = cast . cast {to=Integer} . sqrt . cast 36 | 37 | toN : Nat -> List Nat 38 | toN = reverse . ana naturals 39 | 40 | isPrime : Nat -> List Nat -> Bool 41 | isPrime n ns = all (\a => mod n a /= 0) (filter (<= (roundedSqrt n)) ns) 42 | 43 | dedup : (Eq a) => List a -> List a 44 | dedup = para pseudoalgebra where 45 | pseudoalgebra : (Eq a) => ListF a (List a, List a) -> List a 46 | pseudoalgebra NilF = [] 47 | pseudoalgebra (Cons x (past, xs)) = if elem x past then xs else x :: xs 48 | 49 | evenOdd : Nat -> Bool 50 | evenOdd = mutu odd even where 51 | odd : Maybe (Bool, Bool) -> Bool 52 | odd Nothing = False 53 | odd (Just (_, b)) = b 54 | even : Maybe (Bool, Bool) -> Bool 55 | even Nothing = True 56 | even (Just (_, b)) = b 57 | 58 | collatzCoalgebra : Int -> Either (List Int) (ListF Int Int) 59 | collatzCoalgebra 1 = Left [1] 60 | collatzCoalgebra 2 = Left [2, 1] 61 | collatzCoalgebra 3 = Left [3, 10, 5, 16, 8, 4, 2, 1] 62 | collatzCoalgebra 4 = Left [6, 3, 10, 5, 16, 8, 4, 2, 1] 63 | collatzCoalgebra n with (modInt n 2) 64 | | 0 = Right $ Cons n (divInt n 2) 65 | | _ = Right $ Cons n (3 * n + 1) 66 | 67 | collatz : Int -> List Int 68 | collatz = micro collatzCoalgebra 69 | 70 | elgotCoalgebra : List a -> Either (List (List a)) (ListF (List a) (List a)) 71 | elgotCoalgebra [] = Right NilF 72 | elgotCoalgebra (x :: []) = Left ([[x]]) 73 | elgotCoalgebra (x :: xs) = Right (Cons (x :: xs) xs) 74 | 75 | -- fibonacci zygomorphism? 76 | 77 | zygoPseudoalgebra : ListF Int (Bool, Int) -> Int 78 | zygoPseudoalgebra NilF = 0 79 | zygoPseudoalgebra (Cons n (b, x)) = if b then (n+x) else (n-x) 80 | 81 | zygoAlgebra : ListF Int Bool -> Bool 82 | zygoAlgebra NilF = False 83 | zygoAlgebra (Cons _ bool) = not bool 84 | 85 | plusMinus : List Int -> Int 86 | plusMinus = zygo zygoAlgebra zygoPseudoalgebra 87 | 88 | algebra' : ListF (List a) (List a) -> List a 89 | algebra' NilF = [] 90 | algebra' (Cons x xs) = x ++ xs 91 | 92 | cataConcat : List (List a) -> List a 93 | cataConcat = cata algebra' 94 | 95 | algebra : ListF (List a) (List (List a)) -> List (List a) 96 | algebra NilF = [] 97 | algebra (Cons x xs) = x::xs 98 | 99 | coalgebra : List a -> ListF (List a) (List a) 100 | coalgebra (x::xs) = Cons (x::xs) xs 101 | coalgebra [] = NilF 102 | 103 | suffix : List a -> List (List a) 104 | suffix = hylo algebra coalgebra . drop 1 105 | 106 | export 107 | specSuite : IO () 108 | specSuite = 109 | spec $ do 110 | describe "hylo" $ 111 | it "should be able to implement the suffix function" $ 112 | (suffix . unpack) "ego" `shouldBe` [['g','o'], ['o']] 113 | describe "cata" $ 114 | it "should be able to implement 'concat'" $ 115 | (cataConcat . map unpack) [ "I", "am" ] `shouldBe` ['I', 'a', 'm'] 116 | describe "zygo" $ 117 | it "should be able to implement plusMinus" $ 118 | plusMinus [1,2,3] `shouldBe` -4 119 | describe "micro" $ 120 | it "should provide a simple way to compute the Collatz sequence associated with a number" $ 121 | collatz 12 `shouldBe` [12, 6, 3, 10, 5, 16, 8, 4, 2, 1] 122 | describe "mutu" $ 123 | it "should be able to do recursion on the natural numbers to check for parity" $ 124 | (evenOdd . fromIntegerNat) 10 `shouldBe` True 125 | describe "para" $ 126 | it "should provide an elegant way to remove duplicates from a list when order doesn't matter" $ 127 | dedup [1,1,2,3,4,5,4] `shouldBe` [1,2,3,5,4] 128 | describe "dyna" $ 129 | it "should do something with catalan numbers" $ 130 | catalan 6 `shouldBe` 132 131 | describe "ana" $ 132 | it "should give the first n naturals" $ 133 | toN 5 `shouldBe` [1,2,3,4,5] 134 | -------------------------------------------------------------------------------- /docs/IdrisDoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmchale/recursion_schemes/e10780a16028a6f8fe418d8251578a7d1c43ebe8/docs/IdrisDoc -------------------------------------------------------------------------------- /docs/docs/Control.Comonad.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Control.Comonad
IdrisDoc: Control.Comonad

Control.Comonad

Module providing comonads for idris.

3 |
liftW : Comonad w => 4 | (f : a -> 5 | b) -> 6 | w a -> 7 | w b

Lift a function into a function on comonadic values.

8 |
extend : Comonad w => 9 | (w a -> 10 | b) -> 11 | w a -> 12 | w b
interface Comonad 

A comonad is the categorical dual of a monad. It must satisfy the following
13 | laws:

14 |
extend extract      = id
15 | extract . extend f  = f
16 | extend f . extend g = extend (f . extend g)
17 | 
18 |
extract : Comonad w => 19 | w a -> 20 | a
duplicate : Comonad w => 21 | w a -> 22 | w (w a)
interface CoApplicative 

CoApplicatives provide a categorical approach to zippers. They must satisfy
23 | the following laws:

24 |
(.) <$> u <@> v <@> w = u <@> (v <@> w)
25 | extract (p <@> q) = extract p (extract q)
26 | duplicate (p <@> q) = (<@>) <$> duplicate p <@> duplicate q
27 | 
28 |

If 'w' is an applicative functor, it must further satisfy

29 |
(<@>) = (<*>)
30 | 
31 |
(<@>) : CoApplicative w => 32 | w (a -> 33 | b) -> 34 | w a -> 35 | w b
Fixity
Left associative, precedence 4
(@>) : CoApplicative w => 36 | w a -> 37 | w b -> 38 | w b
Fixity
Left associative, precedence 4
(<@) : CoApplicative w => 39 | w a -> 40 | w b -> 41 | w a
Fixity
Left associative, precedence 4
(=>>) : Comonad w => 42 | w a -> 43 | (w a -> 44 | b) -> 45 | w b

Dual to '>>='

46 |
Fixity
Left associative, precedence 1
(=>=) : Comonad w => 47 | (w a -> 48 | b) -> 49 | (w b -> 50 | c) -> 51 | w a -> 52 | c

Left-to-right cokliesli composition

53 |
Fixity
Left associative, precedence 1
(=<=) : Comonad w => 54 | (w b -> 55 | c) -> 56 | (w a -> 57 | b) -> 58 | w a -> 59 | c

Right-to-left cokliesli composition

60 |
Fixity
Left associative, precedence 1
(<<=) : Comonad w => 61 | (w a -> 62 | b) -> 63 | w a -> 64 | w b

Operator giving us 'extend'

65 |
Fixity
Left associative, precedence 1
-------------------------------------------------------------------------------- /docs/docs/Control.Monad.Free.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Control.Monad.Free
IdrisDoc: Control.Monad.Free

Control.Monad.Free

lowerFree : Monad f => 3 | Free f 4 | a -> 5 | f a
liftFree : Functor f => 6 | f a -> 7 | Free f 8 | a
iterM : Monad m => 9 | Functor f => 10 | (f (m a) -> 11 | m a) -> 12 | Free f 13 | a -> 14 | m a
hoistFree : Functor g => 15 | (f a -> 16 | g a) -> 17 | Free f 18 | b -> 19 | Free g 20 | b
foldFree : Monad m => 21 | Functor f => 22 | (f a -> 23 | m a) -> 24 | Free f 25 | b -> 26 | m b
interface MonadFree 
wrap : MonadFree m 27 | f => 28 | f (m a) -> 29 | m a
data Free : (f : Type -> 30 | Type) -> 31 | (a : Type) -> 32 | Type
Pure : a -> 33 | Free f 34 | a
Bind : f (Free f 35 | a) -> 36 | Free f 37 | a
-------------------------------------------------------------------------------- /docs/docs/Control.Monad.Identity.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Control.Monad.Identity
IdrisDoc: Control.Monad.Identity

Control.Monad.Identity

record Identity a
a
 
Id : (runIdentity : a) -> 3 | Identity a
runIdentity : (rec : Identity a) -> 4 | a
Id : (runIdentity : a) -> 5 | Identity a
-------------------------------------------------------------------------------- /docs/docs/Data.Functor.Foldable.Exotic.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Data.Functor.Foldable.Exotic
IdrisDoc: Data.Functor.Foldable.Exotic

Data.Functor.Foldable.Exotic

micro : Functor f => 3 | Corecursive f 4 | a => 5 | (b -> 6 | Either a 7 | (f b)) -> 8 | b -> 9 | a

Anamorphism that allows shortcuts.

10 |
mhisto : ((y -> 11 | c) -> 12 | (y -> 13 | f y) -> 14 | f y -> 15 | c) -> 16 | Fix f -> 17 | c

Mendler's histomorphism

18 |
meta : Functor f => 19 | Corecursive f 20 | t' => 21 | Recursive g 22 | t => 23 | (a -> 24 | f a) -> 25 | (b -> 26 | a) -> 27 | (g b -> 28 | b) -> 29 | t -> 30 | t'

Gibbons' metamorphism. Tear down a structure, transform it, and then build up a new structure

31 |
mcata : ((y -> 32 | c) -> 33 | f y -> 34 | c) -> 35 | Fix f -> 36 | c

Mendler's catamorphism

37 |
hyloPro : Functor f => 38 | Functor g => 39 | (f a -> 40 | a) -> 41 | (g c -> 42 | f c) -> 43 | (b -> 44 | g b) -> 45 | b -> 46 | a

Erwig's metamorphism. Essentially a hylomorphism with a natural
47 | transformation in between. This allows us to use more than one functor in a
48 | hylomorphism.

49 |
elgot : Functor f => 50 | (f a -> 51 | a) -> 52 | (b -> 53 | Either a 54 | (f b)) -> 55 | b -> 56 | a

Elgot algebra (see this paper)

57 |
dynaPro : Functor f => 58 | Functor g => 59 | (f (Cofree f 60 | a) -> 61 | a) -> 62 | (g c -> 63 | f c) -> 64 | (b -> 65 | g b) -> 66 | b -> 67 | a

A dynamorphism builds up with an anamorphism and tears down with a
68 | histomorphism. Useful for lexical scoping.

69 |
dyna : Functor f => 70 | (f (Cofree f 71 | a) -> 72 | a) -> 73 | (b -> 74 | f b) -> 75 | b -> 76 | a

A dynamorphism without a natural transformation in between.

77 |
coelgot : Functor f => 78 | ((a, 79 | f b) -> 80 | b) -> 81 | (a -> 82 | f a) -> 83 | a -> 84 | b

Elgot coalgebra

85 |
(.*) : (c -> 86 | d) -> 87 | (a -> 88 | b -> 89 | c) -> 90 | a -> 91 | b -> 92 | d
Fixity
Left associative, precedence 9
-------------------------------------------------------------------------------- /docs/docs/Data.Functor.Foldable.Instances.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Data.Functor.Foldable.Instances
IdrisDoc: Data.Functor.Foldable.Instances

Data.Functor.Foldable.Instances

unfix : Fix f -> 3 | f (Fix f)

Unfix a 'Fix f'

4 |
lambek : Recursive f 5 | t => 6 | Corecursive f 7 | t => 8 | t -> 9 | f t

Lambek's lemma assures us this function always exists.

10 |
fix : f (Fix f) -> 11 | Fix f

Create a fix-point with a functor

12 |
colambek : Recursive f 13 | t => 14 | Corecursive f 15 | t => 16 | f t -> 17 | t

The dual of Lambek's lemma.

18 |
data StreamF : Type -> 19 | Type -> 20 | Type
Pipe : a -> 21 | b -> 22 | StreamF a 23 | b
data Nu : (f : Type -> 24 | Type) -> 25 | Type -> 26 | Type

Nu fix-point functor for coinduction

27 |
NuF : ((a -> 28 | f a) -> 29 | a) -> 30 | b -> 31 | Nu f 32 | b
data Mu : (Type -> 33 | Type) -> 34 | Type

Mu fix-point functor for induction

35 |
MuF : ((a -> 36 | f a) -> 37 | a) -> 38 | Mu f
data ListF : Type -> 39 | Type -> 40 | Type
NilF : ListF _ 41 | _
Cons : a -> 42 | b -> 43 | ListF a 44 | b
data Fix : (Type -> 45 | Type) -> 46 | Type

Fix-point data type for exotic recursion schemes of various kinds

47 |
Fx : f (Fix f) -> 48 | Fix f
-------------------------------------------------------------------------------- /docs/docs/Data.Profunctor.Comonad.Cofree.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Data.Profunctor.Comonad.Cofree
IdrisDoc: Data.Profunctor.Comonad.Cofree

Data.Profunctor.Comonad.Cofree

Cofree comonads; useful for histomorphisms and also recursion

3 |
unfold : Functor f => 4 | (g : b -> 5 | (a, 6 | f b)) -> 7 | b -> 8 | Cofree f 9 | a

Recursion using comonads

10 |
interface ComonadCofree 

Typeclass for cofree comonads

11 |
unwrap : ComonadCofree f 12 | w => 13 | w a -> 14 | f (w a)
data Cofree : (f : Type -> 15 | Type) -> 16 | Type -> 17 | Type

Constructor for a cofree comonad

18 |
Co : a -> 19 | f (Cofree f 20 | a) -> 21 | Cofree f 22 | a
-------------------------------------------------------------------------------- /docs/docs/Decidable.Equality.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Decidable.Equality
IdrisDoc: Decidable.Equality

Decidable.Equality

trueNotFalse : (True = 3 | False) -> 4 | Void
nothingNotJust : (Nothing = 5 | Just x) -> 6 | Void
negEqSym : ((a = 7 | b) -> 8 | Void) -> 9 | (b = 10 | a) -> 11 | Void

The negation of equality is symmetric (follows from symmetry of equality)

12 |
lemma_x_neq_xs_neq : ((x = 13 | y) -> 14 | Void) -> 15 | ((xs = 16 | ys) -> 17 | Void) -> 18 | (x :: 19 | xs = 20 | y :: 21 | ys) -> 22 | Void
lemma_x_neq_xs_eq : ((x = 23 | y) -> 24 | Void) -> 25 | (xs = 26 | ys) -> 27 | (x :: 28 | xs = 29 | y :: 30 | ys) -> 31 | Void
lemma_x_eq_xs_neq : (x = 32 | y) -> 33 | ((xs = 34 | ys) -> 35 | Void) -> 36 | (x :: 37 | xs = 38 | y :: 39 | ys) -> 40 | Void
lemma_val_not_nil : (x :: 41 | xs = 42 | []) -> 43 | Void
lemma_snd_neq : (x = 44 | x) -> 45 | ((y = 46 | y') -> 47 | Void) -> 48 | ((x, 49 | y) = 50 | (x, 51 | y')) -> 52 | Void
lemma_fst_neq_snd_eq : ((x = 53 | x') -> 54 | Void) -> 55 | (y = 56 | y') -> 57 | ((x, 58 | y) = 59 | (x', 60 | y)) -> 61 | Void
lemma_both_neq : ((x = 62 | x') -> 63 | Void) -> 64 | ((y = 65 | y') -> 66 | Void) -> 67 | ((x, 68 | y) = 69 | (x', 70 | y')) -> 71 | Void
leftNotRight : (Left x = 72 | Right y) -> 73 | Void
decEqSelfIsYes : DecEq a => 74 | decEq x 75 | x = 76 | Yes Refl

Everything is decidably equal to itself

77 |
ZnotS : (0 = 78 | S n) -> 79 | Void
interface DecEq 

Decision procedures for propositional equality

80 |
decEq : DecEq t => 81 | (x1 : t) -> 82 | (x2 : t) -> 83 | Dec (x1 = 84 | x2)

Decide whether two elements of t are propositionally equal

85 |
-------------------------------------------------------------------------------- /docs/docs/FFI.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: FFI
IdrisDoc: FFI

FFI

set_ffi_types : (ffi_types : Type -> 3 | Type) -> 4 | (rec : FFI) -> 5 | FFI

A family describing which types are available in the FFI

6 |
set_ffi_fn : (ffi_fn : Type) -> 7 | (rec : FFI) -> 8 | FFI

The type used to specify the names of foreign functions in this FFI

9 |
set_ffi_data : (ffi_data : Type) -> 10 | (rec : FFI) -> 11 | FFI

How this FFI describes exported datatypes

12 |
ffi_types : (rec : FFI) -> 13 | Type -> 14 | Type

A family describing which types are available in the FFI

15 |
ffi_fn : (rec : FFI) -> 16 | Type

The type used to specify the names of foreign functions in this FFI

17 |
ffi_data : (rec : FFI) -> 18 | Type

How this FFI describes exported datatypes

19 |
-------------------------------------------------------------------------------- /docs/docs/FFI_C.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: FFI_C
IdrisDoc: FFI_C

FFI_C

data Raw : Type -> 3 | Type
MkRaw : (x : t) -> 4 | Raw t
FFI_C : FFI

A descriptor for the C FFI. See the constructors of C_Types
5 | and C_IntTypes for the concrete types that are available.

6 |
data C_Types : Type -> 7 | Type

Supported C foreign types

8 |
C_Str : C_Types String
C_Float : C_Types Double
C_Ptr : C_Types Ptr
C_MPtr : C_Types ManagedPtr
C_Unit : C_Types ()
C_Any : C_Types (Raw a)
C_FnT : C_FnTypes t -> 9 | C_Types (CFnPtr t)
C_IntT : C_IntTypes i -> 10 | C_Types i
C_CData : C_Types CData
data C_IntTypes : Type -> 11 | Type

Supported C integer types

12 |
C_IntChar : C_IntTypes Char
C_IntNative : C_IntTypes Int
C_IntBits8 : C_IntTypes Bits8
C_IntBits16 : C_IntTypes Bits16
C_IntBits32 : C_IntTypes Bits32
C_IntBits64 : C_IntTypes Bits64
data C_FnTypes : Type -> 13 | Type
C_Fn : C_Types s -> 14 | C_FnTypes t -> 15 | C_FnTypes (s -> 16 | t)
C_FnIO : C_Types t -> 17 | C_FnTypes (IO' FFI_C 18 | t)
C_FnBase : C_Types t -> 19 | C_FnTypes t
data CFnPtr : Type -> 20 | Type
MkCFnPtr : (x : t) -> 21 | CFnPtr t
-------------------------------------------------------------------------------- /docs/docs/ForeignEnv.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: ForeignEnv
IdrisDoc: ForeignEnv

ForeignEnv

data FEnv : FFI -> 3 | List Type -> 4 | Type
Nil : FEnv f 5 | []
(::) : (ffi_types f 6 | t, 7 | t) -> 8 | FEnv f 9 | xs -> 10 | FEnv f 11 | (t :: 12 | xs)
Fixity
Left associative, precedence 7
-------------------------------------------------------------------------------- /docs/docs/Prelude.Algebra.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Algebra
IdrisDoc: Prelude.Algebra

Prelude.Algebra

interface Semigroup 

Sets equipped with a single binary operation that is associative. Must
3 | satisfy the following laws:

4 |
    5 |
  • Associativity of <+>:
    6 | forall a b c, a <+> (b <+> c) == (a <+> b) <+> c
  • 7 |
8 |
(<+>) : Semigroup ty => 9 | ty -> 10 | ty -> 11 | ty
Fixity
Left associative, precedence 6
interface Monoid 

Sets equipped with a single binary operation that is associative, along with
12 | a neutral element for that binary operation. Must satisfy the following
13 | laws:

14 |
    15 |
  • Associativity of <+>:
    16 | forall a b c, a <+> (b <+> c) == (a <+> b) <+> c
  • 17 |
  • Neutral for <+>:
    18 | forall a, a <+> neutral == a
    19 | forall a, neutral <+> a == a
  • 20 |
21 |
neutral : Monoid ty => 22 | ty
-------------------------------------------------------------------------------- /docs/docs/Prelude.Basics.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Basics
IdrisDoc: Prelude.Basics

Prelude.Basics

the : (a : Type) -> 3 | (value : a) -> 4 | a

Manually assign a type to an expression.

5 |
a

the type to assign

6 |
value

the element to get the type

7 |
snd : (a, 8 | b) -> 9 | b

Return the second element of a pair.

10 |
id : a -> 11 | a

Identity function.

12 |
fst : (a, 13 | b) -> 14 | a

Return the first element of a pair.

15 |
flip : (f : a -> 16 | b -> 17 | c) -> 18 | b -> 19 | a -> 20 | c

Takes in the first two arguments in reverse order.

21 |
f

the function to flip

22 |
const : a -> 23 | b -> 24 | a

Constant function. Ignores its second argument.

25 |
cong : (a = 26 | b) -> 27 | f a = 28 | f b

Equality is a congruence.

29 |
apply : (a -> 30 | b) -> 31 | a -> 32 | b

Function application.

33 |
Not : Type -> 34 | Type
data Dec : Type -> 35 | Type

Decidability. A decidable property either holds or is a contradiction.

36 |
Yes : (prf : prop) -> 37 | Dec prop

The case where the property holds

38 |
prf

the proof

39 |
No : (contra : prop -> 40 | Void) -> 41 | Dec prop

The case where the property holding would be a contradiction

42 |
contra

a demonstration that prop would be a contradiction

43 |
(.) : (b -> 44 | c) -> 45 | (a -> 46 | b) -> 47 | a -> 48 | c

Function composition

49 |
Fixity
Left associative, precedence 9
-------------------------------------------------------------------------------- /docs/docs/Prelude.Bool.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Bool
IdrisDoc: Prelude.Bool

Prelude.Bool

(||) : Bool -> 3 | Lazy Bool -> 4 | Bool

Boolean OR only evaluates the second argument if the first is False.

5 |
Fixity
Left associative, precedence 4
not : Bool -> 6 | Bool

Boolean NOT

7 |
ifThenElse : (b : Bool) -> 8 | (t : Lazy a) -> 9 | (e : Lazy a) -> 10 | a

The underlying implementation of the if ... then ... else ... syntax

11 |
b

the condition on the if

12 |
t

the value if b is true

13 |
e

the falue if b is false

14 |
data Bool : Type

Boolean Data Type

15 |
False : Bool
True : Bool
(&&) : Bool -> 16 | Lazy Bool -> 17 | Bool

Boolean AND only evaluates the second argument if the first is True.

18 |
Fixity
Left associative, precedence 5
-------------------------------------------------------------------------------- /docs/docs/Prelude.Either.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Either
IdrisDoc: Prelude.Either

Prelude.Either

rights : List (Either a 3 | b) -> 4 | List b

Keep the payloads of all Right constructors in a list of Eithers

5 |
rightInjective : (Right x = 6 | Right y) -> 7 | x = 8 | y

Right is injective

9 |
partitionEithers : List (Either a 10 | b) -> 11 | (List a, 12 | List b)

Split a list of Eithers into a list of the left elements and a list of the right elements

13 |
mirror : Either a 14 | b -> 15 | Either b 16 | a

Right becomes left and left becomes right

17 |
maybeToEither : (def : Lazy e) -> 18 | Maybe a -> 19 | Either e 20 | a

Convert a Maybe to an Either by using a default value in case of Nothing

21 |
e

the default value

22 |
lefts : List (Either a 23 | b) -> 24 | List a

Keep the payloads of all Left constructors in a list of Eithers

25 |
leftInjective : (Left x = 26 | Left y) -> 27 | x = 28 | y

Left is injective

29 |
isRight : Either a 30 | b -> 31 | Bool

True if the argument is Right, False otherwise

32 |
isLeft : Either a 33 | b -> 34 | Bool

True if the argument is Left, False otherwise

35 |
fromEither : Either a 36 | a -> 37 | a

Remove a "useless" Either by collapsing the case distinction

38 |
either : (f : Lazy (a -> 39 | c)) -> 40 | (g : Lazy (b -> 41 | c)) -> 42 | (e : Either a 43 | b) -> 44 | c

Simply-typed eliminator for Either

45 |
f

the action to take on Left

46 |
g

the action to take on Right

47 |
e

the sum to analyze

48 |
data Either : (a : Type) -> 49 | (b : Type) -> 50 | Type

A sum type

51 |
Left : (l : a) -> 52 | Either a 53 | b

One possibility of the sum, conventionally used to represent errors

54 |
Right : (r : b) -> 55 | Either a 56 | b

The other possibility, conventionally used to represent success

57 |
-------------------------------------------------------------------------------- /docs/docs/Prelude.File.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.File
IdrisDoc: Prelude.File

Prelude.File

writeFile : (filepath : String) -> 3 | (contents : String) -> 4 | IO (Either FileError 5 | ())

Write a string to a file

6 |
validFile : File -> 7 | IO Bool

Check whether a file handle is actually a null pointer

8 |
stdout : File

Standard output

9 |
stdin : File

Standard input

10 |
stderr : File

Standard output

11 |
readFile : (filepath : String) -> 12 | IO (Either FileError 13 | String)

Read the contents of a text file into a string
14 | This checks the size of the file before beginning to read, and only
15 | reads that many bytes, to ensure that it remains a total function if
16 | the file is appended to while being read.
17 | This only works reliably with text files, since it relies on null-terminated
18 | strings internally.
19 | Returns an error if filepath is not a normal file.

20 |
popen : String -> 21 | Mode -> 22 | IO (Either FileError 23 | File)
pclose : File -> 24 | IO ()
openFileX : (f : String) -> 25 | (m : Mode) -> 26 | IO (Either FileError 27 | File)

Open a file using C11 extended modes.

28 |
f

the filename

29 |
m

the mode; either Read, WriteTruncate, Append, ReadWrite, ReadWriteTruncate, or ReadAppend

30 |
openFile : (f : String) -> 31 | (m : Mode) -> 32 | IO (Either FileError 33 | File)

Open a file

34 |
f

the filename

35 |
m

the mode; either Read, WriteTruncate, Append, ReadWrite, ReadWriteTruncate, or ReadAppend

36 |
modeStr : Mode -> 37 | String
getFileError : IO FileError
fpoll : File -> 38 | IO Bool
fopen : (f : String) -> 39 | (m : String) -> 40 | IO (Either FileError 41 | File)

Open a file

42 |
f

the filename

43 |
m

the mode as a String ("r", "w", or "r+")

44 |
fileStatusTime : File -> 45 | IO (Either FileError 46 | Integer)
fileSize : File -> 47 | IO (Either FileError 48 | Int)

Return the size of a File
49 | Returns an error if the File is not an ordinary file (e.g. a directory)
50 | Also note that this currently returns an Int, which may overflow if the
51 | file is very big

52 |
fileModifiedTime : File -> 53 | IO (Either FileError 54 | Integer)
fileAccessTime : File -> 55 | IO (Either FileError 56 | Integer)
fgetc : File -> 57 | IO (Either FileError 58 | Char)
fflush : File -> 59 | IO ()
ferror : File -> 60 | IO Bool
fPutStrLn : File -> 61 | String -> 62 | IO (Either FileError 63 | ())
fPutStr : (h : File) -> 64 | (str : String) -> 65 | IO (Either FileError 66 | ())

Write a line to a file

67 |
h

a file handle which must be open for writing

68 |
str

the line to write to the file

69 |
fGetLine : (h : File) -> 70 | IO (Either FileError 71 | String)

Read a line from a file

72 |
h

a file handle which must be open for reading

73 |
fGetChars : (h : File) -> 74 | (len : Int) -> 75 | IO (Either FileError 76 | String)

Read up to a number of characters from a file

77 |
h

a file handle which must be open for reading

78 |
fEOF : File -> 79 | IO Bool

Check if a file handle has reached the end

80 |
dirOpen : (d : String) -> 81 | IO (Either FileError 82 | Directory)
dirError : Directory -> 83 | IO Bool
dirEntry : Directory -> 84 | IO (Either FileError 85 | String)
dirClose : Directory -> 86 | IO ()
createDir : String -> 87 | IO (Either FileError 88 | ())
closeFile : File -> 89 | IO ()
changeDir : String -> 90 | IO Bool
data Mode : Type

Modes for opening files

91 |
Read : Mode
WriteTruncate : Mode
Append : Mode
ReadWrite : Mode
ReadWriteTruncate : Mode
ReadAppend : Mode
data FileError : Type

An error from a file operation

92 |
GenericFileError : Int -> 93 | FileError
FileReadError : FileError
FileWriteError : FileError
FileNotFound : FileError
PermissionDenied : FileError
data File : Type

A file handle

94 |
FHandle : (p : Ptr) -> 95 | File
data Directory : Type

A directory handle

96 |
DHandle : (p : Ptr) -> 97 | Directory
-------------------------------------------------------------------------------- /docs/docs/Prelude.Foldable.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Foldable
IdrisDoc: Prelude.Foldable

Prelude.Foldable

sum : Foldable t => 3 | Num a => 4 | t a -> 5 | a

Add together all the elements of a structure

6 |
product : Foldable t => 7 | Num a => 8 | t a -> 9 | a

Multiply together all elements of a structure

10 |
or : Foldable t => 11 | t (Lazy Bool) -> 12 | Bool

The disjunction of all elements of a structure containing
13 | lazy boolean values. or short-circuits from left to right, evaluating
14 | either until an element is True or no elements remain.

15 |
default#foldl : Foldable t => 16 | (func : acc -> 17 | elem -> 18 | acc) -> 19 | (init : acc) -> 20 | (input : t elem) -> 21 | acc
concatMap : Foldable t => 22 | Monoid m => 23 | (a -> 24 | m) -> 25 | t a -> 26 | m

Combine into a monoid the collective results of applying a function
27 | to each element of a structure

28 |
concat : Foldable t => 29 | Monoid a => 30 | t a -> 31 | a

Combine each element of a structure into a monoid

32 |
any : Foldable t => 33 | (a -> 34 | Bool) -> 35 | t a -> 36 | Bool

The disjunction of the collective results of applying a
37 | predicate to all elements of a structure. any short-circuits
38 | from left to right.

39 |
and : Foldable t => 40 | t (Lazy Bool) -> 41 | Bool

The conjunction of all elements of a structure containing
42 | lazy boolean values. and short-circuits from left to right,
43 | evaluating until either an element is False or no elements remain.

44 |
all : Foldable t => 45 | (a -> 46 | Bool) -> 47 | t a -> 48 | Bool

The disjunction of the collective results of applying a
49 | predicate to all elements of a structure. all short-circuits
50 | from left to right.

51 |
interface Foldable 

The Foldable interface describes how you can iterate over the
52 | elements in a parameterised type and combine the elements
53 | together, using a provided function, into a single result.

54 |
foldr : Foldable t => 55 | (func : elem -> 56 | acc -> 57 | acc) -> 58 | (init : acc) -> 59 | (input : t elem) -> 60 | acc

Successively combine the elements in a parameterised type using
61 | the provided function, starting with the element that is in the
62 | final position i.e. the right-most position.

63 |
foldl : Foldable t => 64 | (func : acc -> 65 | elem -> 66 | acc) -> 67 | (init : acc) -> 68 | (input : t elem) -> 69 | acc

The same as foldr but begins the folding from the element at
70 | the initial position in the data structure i.e. the left-most
71 | position.

72 |
-------------------------------------------------------------------------------- /docs/docs/Prelude.Functor.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Functor
IdrisDoc: Prelude.Functor

Prelude.Functor

ignore : Functor f => 3 | f a -> 4 | f ()

Run something for effects, throwing away the return value

5 |
interface Functor 

Functors allow a uniform action over a parameterised type.

6 |
map : Functor f => 7 | (func : a -> 8 | b) -> 9 | f a -> 10 | f b

Apply a function across everything of type 'a' in a
11 | parameterised type

12 |
(<$>) : Functor f => 13 | (func : a -> 14 | b) -> 15 | f a -> 16 | f b

An infix alias for map, applying a function across everything of
17 | type 'a' in a parameterised type

18 |
Fixity
Left associative, precedence 4
f

the parameterised type

19 |
func

the function to apply

20 |
-------------------------------------------------------------------------------- /docs/docs/Prelude.Maybe.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Maybe
IdrisDoc: Prelude.Maybe

Prelude.Maybe

toMaybe : Bool -> 3 | Lazy a -> 4 | Maybe a

Returns Just the given value if the conditional is True
5 | and Nothing if the conditional is False.

6 |
raiseToMaybe : Monoid a => 7 | Eq a => 8 | a -> 9 | Maybe a

Returns Nothing when applied to neutral, and Just the value otherwise.

10 |
maybe_bind : Maybe a -> 11 | (a -> 12 | Maybe b) -> 13 | Maybe b
maybe : Lazy b -> 14 | Lazy (a -> 15 | b) -> 16 | Maybe a -> 17 | b
lowerMaybe : Monoid a => 18 | Maybe a -> 19 | a

Convert a Maybe a value to an a value, using neutral in the case
20 | that the Maybe value is Nothing.

21 |
justInjective : (Just x = 22 | Just y) -> 23 | x = 24 | y
isNothing : Maybe a -> 25 | Bool
isJust : Maybe a -> 26 | Bool
isItJust : (v : Maybe a) -> 27 | Dec (IsJust v)

Decide whether a 'Maybe' is 'Just'

28 |
fromMaybe : Lazy a -> 29 | Maybe a -> 30 | a

Convert a Maybe a value to an a value by providing a default a value
31 | in the case that the Maybe value is Nothing.

32 |
collectJust : Semigroup a => 33 | Semigroup (Maybe a)

Transform any semigroup into a monoid by using Nothing as the
34 | designated neutral element and collecting the contents of the
35 | Just constructors using a semigroup structure on a. This is
36 | the behaviour in the Haskell libraries.

37 |
data Maybe : (a : Type) -> 38 | Type

An optional value. This can be used to represent the possibility of
39 | failure, where a function may return a value, or not.

40 |
Nothing : Maybe a

No value stored

41 |
Just : (x : a) -> 42 | Maybe a

A value of type a is stored

43 |
data IsJust : Maybe a -> 44 | Type

Proof that some Maybe is actually Just

45 |
ItIsJust : IsJust (Just x)
-------------------------------------------------------------------------------- /docs/docs/Prelude.Monad.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Monad
IdrisDoc: Prelude.Monad

Prelude.Monad

Monads and Functors

3 |
return : Monad m => 4 | a -> 5 | m a

For compatibility with Haskell. Note that monads are not free to
6 | define return and pure differently!

7 |
foldlM : Foldable t => 8 | Monad m => 9 | (funcM : a -> 10 | b -> 11 | m a) -> 12 | (init : a) -> 13 | (input : t b) -> 14 | m a

Similar to foldl, but uses a function wrapping its result in a Monad.
15 | Consequently, the final value is wrapped in the same Monad.

16 |
default#join : Monad m => 17 | m (m a) -> 18 | m a
default#>>= : Monad m => 19 | m a -> 20 | (a -> 21 | m b) -> 22 | m b
interface Monad 
(>>=) : Monad m => 23 | m a -> 24 | (a -> 25 | m b) -> 26 | m b

Also called bind.

27 |
Fixity
Left associative, precedence 1
join : Monad m => 28 | m (m a) -> 29 | m a

Also called flatten or mu

30 |
-------------------------------------------------------------------------------- /docs/docs/Prelude.Show.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Show
IdrisDoc: Prelude.Show

Prelude.Show

showParens : (b : Bool) -> 3 | String -> 4 | String

Surround a String with parentheses depending on a condition.

5 |
b

whether to add parentheses

6 |
showLitString : List Char -> 7 | String -> 8 | String
showLitChar : Char -> 9 | String -> 10 | String
showCon : (d : Prec) -> 11 | (conName : String) -> 12 | (shownArgs : String) -> 13 | String

A helper for the common case of showing a non-infix constructor with at
14 | least one argument, for use with showArg.

15 |

Apply showCon to the precedence context, the constructor name, and the
16 | args shown with showArg and concatenated. Example:

17 |
data Ann a = MkAnn String a
18 | 
19 | Show a => Show (Ann a) where
20 | showPrec d (MkAnn s x) = showCon d "MkAnn" $ showArg s ++ showArg x
21 | 
22 |
showArg : Show a => 23 | (x : a) -> 24 | String

A helper for the common case of showing a non-infix constructor with at
25 | least one argument, for use with showCon.

26 |

This adds a space to the front so the results can be directly
27 | concatenated. See showCon for details and an example.

28 |
protectEsc : (Char -> 29 | Bool) -> 30 | String -> 31 | String -> 32 | String
primNumShow : (a -> 33 | String) -> 34 | Prec -> 35 | a -> 36 | String
precCon : Prec -> 37 | Integer

Gives the constructor index of the Prec as a helper for writing implementations.

38 |
firstCharIs : (Char -> 39 | Bool) -> 40 | String -> 41 | Bool
default#showPrec : Show ty => 42 | (d : Prec) -> 43 | (x : ty) -> 44 | String
default#show : Show ty => 45 | (x : ty) -> 46 | String
interface Show 

Things that have a canonical String representation.

47 |
show : Show ty => 48 | (x : ty) -> 49 | String

Convert a value to its String representation.

50 |
showPrec : Show ty => 51 | (d : Prec) -> 52 | (x : ty) -> 53 | String

Convert a value to its String representation in a certain precedence
54 | context.

55 |

A value should produce parentheses around itself if and only if the given
56 | precedence context is greater than or equal to the precedence of the
57 | outermost operation represented in the produced String. This is
58 | different from Haskell
, which requires it to be strictly greater. Open
59 | should thus always produce no outermost parens, App should always
60 | produce outermost parens except on atomic values and those that provide
61 | their own bracketing, like Pair and List.

62 |
data Prec : Type

The precedence of an Idris operator or syntactic context.

63 |
Open : Prec
Eq : Prec
Dollar : Prec
Backtick : Prec
User : Nat -> 64 | Prec
PrefixMinus : Prec
App : Prec
-------------------------------------------------------------------------------- /docs/docs/Prelude.Stream.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc: Prelude.Stream
IdrisDoc: Prelude.Stream

Prelude.Stream

zipWith3 : (a -> 3 | b -> 4 | c -> 5 | d) -> 6 | Stream a -> 7 | Stream b -> 8 | Stream c -> 9 | Stream d

Combine three streams by applying a function element-wise along them

10 |
zipWith : (f : a -> 11 | b -> 12 | c) -> 13 | (xs : Stream a) -> 14 | (ys : Stream b) -> 15 | Stream c

Combine two streams element-wise using a function.

16 |
f

the function to combine elements with

17 |
xs

the first stream of elements

18 |
ys

the second stream of elements

19 |
zip3 : Stream a -> 20 | Stream b -> 21 | Stream c -> 22 | Stream (a, 23 | b, 24 | c)

Combine three streams into a stream of tuples elementwise

25 |
zip : Stream a -> 26 | Stream b -> 27 | Stream (a, 28 | b)

Create a stream of pairs from two streams

29 |
unzip3 : Stream (a, 30 | b, 31 | c) -> 32 | (Stream a, 33 | Stream b, 34 | Stream c)

Split a stream of three-element tuples into three streams

35 |
unzip : Stream (a, 36 | b) -> 37 | (Stream a, 38 | Stream b)

Create a pair of streams from a stream of pairs

39 |
take : (n : Nat) -> 40 | (xs : Stream a) -> 41 | List a

Take precisely n elements from the stream

42 |
n

how many elements to take

43 |
xs

the stream

44 |
tail : Stream a -> 45 | Stream a

All but the first element

46 |
scanl : (f : a -> 47 | b -> 48 | a) -> 49 | (acc : a) -> 50 | (xs : Stream b) -> 51 | Stream a

Produce a Stream of left folds of prefixes of the given Stream

52 |
f

the combining function

53 |
acc

the initial value

54 |
xs

the Stream to process

55 |
repeat : a -> 56 | Stream a

An infinite stream of repetitions of the same thing

57 |
iterate : (f : a -> 58 | a) -> 59 | (x : a) -> 60 | Stream a

Generate an infinite stream by repeatedly applying a function

61 |
f

the function to iterate

62 |
x

the initial value that will be the head of the stream

63 |
index : Nat -> 64 | Stream a -> 65 | a

Get the nth element of a stream

66 |
head : Stream a -> 67 | a

The first element of an infinite stream

68 |
drop : (n : Nat) -> 69 | Stream a -> 70 | Stream a

Drop the first n elements from the stream

71 |
n

how many elements to drop

72 |
diag : Stream (Stream a) -> 73 | Stream a

Return the diagonal elements of a stream of streams

74 |
cycle : (xs : List a) -> 75 | {auto ok : NonEmpty xs} -> 76 | Stream a

Produce a Stream repeating a sequence

77 |
xs

the sequence to repeat

78 |
ok

proof that the list is non-empty

79 |
data Stream : Type -> 80 | Type

An infinite stream

81 |
(::) : (value : elem) -> 82 | Inf (Stream elem) -> 83 | Stream elem
Fixity
Left associative, precedence 7
-------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | IdrisDoc Index
IdrisDoc

Namespaces

-------------------------------------------------------------------------------- /docs/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | 3 | margin: 0; 4 | padding: 0; 5 | border: 0; 6 | 7 | height: 100%; 8 | 9 | font-family: "Trebuchet MS", Helvetica, sans-serif; 10 | font-size: 11pt; 11 | 12 | background-color: #FFF; 13 | } 14 | 15 | a, a:active, a:visited { 16 | 17 | text-decoration: none; 18 | color: inherit; 19 | } 20 | 21 | a:hover { 22 | 23 | text-decoration: underline; 24 | } 25 | 26 | header { 27 | 28 | padding: 5px 11px; 29 | 30 | border-bottom: 3px solid #659FDB; 31 | box-shadow: 0 -8px 22px 0px; 32 | 33 | background-color: #252525; 34 | color: white; 35 | 36 | font-size: 9pt; 37 | } 38 | 39 | .wrapper { 40 | 41 | min-height: 100%; 42 | } 43 | 44 | header nav, header strong { 45 | 46 | font-size: 11pt; 47 | } 48 | 49 | header nav { 50 | 51 | float: right; 52 | } 53 | 54 | footer { 55 | 56 | height: 30px; 57 | width: 100%; 58 | border-top: 1px solid #AAAAAA; 59 | 60 | margin-top: -31px; 61 | 62 | text-align: center; 63 | color: #666; 64 | line-height: 30px; 65 | font-size: 9pt; 66 | 67 | background: none repeat scroll 0 0 #DDDDDD; 68 | } 69 | 70 | .container { 71 | 72 | padding: 10px 10px 41px 20px; 73 | } 74 | 75 | body.index .container a:visited { 76 | 77 | color: #666; 78 | } 79 | 80 | body.index .container a:hover { 81 | 82 | color: #04819E; 83 | } 84 | 85 | h1 { 86 | 87 | margin: 0; 88 | margin-bottom: 5px; 89 | font-size: 14pt; 90 | 91 | font-family: "Trebuchet MS", Helvetica, sans-serif; 92 | } 93 | 94 | body.namespace h1 { 95 | 96 | border-bottom: 1px solid #BBB; 97 | padding-bottom: 2px; 98 | } 99 | 100 | ul { 101 | 102 | list-style-type: none; 103 | 104 | margin: 0; 105 | padding: 0; 106 | } 107 | 108 | hr { 109 | 110 | margin: 0; 111 | padding: 0; 112 | border: 0; 113 | 114 | border-bottom: 1px solid #BBB; 115 | } 116 | 117 | p { 118 | 119 | margin: 0; 120 | padding: 0; 121 | } 122 | 123 | .code { 124 | 125 | font-family: "Lucida Console", Monaco, monospace; 126 | font-size: 10pt; 127 | } 128 | 129 | .decls { 130 | 131 | margin-top: 15px; 132 | } 133 | 134 | .decls > dt { 135 | 136 | font-family: "Lucida Console", Monaco, monospace; 137 | font-size: 10pt; 138 | line-height: 20px; 139 | 140 | padding: 2px 0; 141 | 142 | border: 1px solid #CCC; 143 | background-color: #F0F0F0; 144 | 145 | display: table; 146 | width: 100%; 147 | } 148 | 149 | .decls > dt > :first-child { 150 | 151 | padding-left: 6px; 152 | } 153 | 154 | .decls > dt > :last-child { 155 | 156 | padding-right: 6px; 157 | } 158 | 159 | .decls > dd { 160 | 161 | margin: 10px 0 10px 20px; 162 | 163 | font-family: Arial, sans-serif; 164 | font-size: 10pt; 165 | } 166 | 167 | .decls > dd > p { 168 | 169 | margin-bottom: 8px; 170 | } 171 | 172 | .decls > dd > dl:not(.decls):not(:first-child) { 173 | 174 | padding-top: 5px; 175 | border-top: 1px solid #EEE; 176 | } 177 | 178 | .decls > dd > dl:not(.decls) > dt { 179 | 180 | display: block; 181 | min-width: 70px; 182 | 183 | float: left; 184 | 185 | font-weight: bold; 186 | } 187 | 188 | .decls > dd > dl:not(.decls) > dd { 189 | 190 | margin-bottom: 2px; 191 | } 192 | 193 | .fixity { 194 | 195 | font-style: italic; 196 | font-weight: normal !important; 197 | } 198 | 199 | dd.fixity { 200 | 201 | cursor: default; 202 | } 203 | 204 | .word { 205 | 206 | display: table-cell; 207 | white-space: nowrap; 208 | width: 0; 209 | } 210 | 211 | .signature { 212 | 213 | display: table-cell; 214 | width: 100%; 215 | } 216 | 217 | .name { 218 | 219 | display: table-cell; 220 | white-space: nowrap; 221 | width: 0; 222 | } 223 | 224 | .documented, .name { 225 | 226 | cursor: default; 227 | } 228 | 229 | .documented { 230 | 231 | font-weight: bold; 232 | } 233 | 234 | a.function { 235 | 236 | color: #00BA00; 237 | } 238 | 239 | .function { 240 | 241 | color: #007C21; 242 | } 243 | 244 | a.constructor { 245 | 246 | color: #FF0000; 247 | } 248 | 249 | .constructor { 250 | 251 | color: #BF3030; 252 | } 253 | 254 | a.type { 255 | 256 | color: #0000FF; 257 | } 258 | 259 | .type { 260 | 261 | color: #050599; 262 | } 263 | 264 | .keyword { 265 | 266 | color: inherit; 267 | } 268 | 269 | .boundvar { 270 | 271 | color: #BF30BF; /* Too much colour makes it hard to differ the rest of the colours */ 272 | color: inherit; 273 | } 274 | 275 | .boundvar.implicit { 276 | 277 | text-decoration: underline; 278 | } 279 | 280 | /******************* Old colours 281 | 282 | a { 283 | 284 | color: #04819E; 285 | } 286 | 287 | a:visited { 288 | 289 | color: #26A3BF; 290 | } 291 | 292 | ********************/ 293 | 294 | ul.names { 295 | 296 | border: 1px solid #666; 297 | } 298 | 299 | ul.names li:nth-child(odd) { 300 | 301 | background-color: #EEEEEF; 302 | } 303 | 304 | ul.names li:nth-child(even) { 305 | 306 | background-color: white; 307 | } 308 | 309 | ul.names li { 310 | 311 | padding-left: 5px; 312 | } 313 | 314 | ul.names li a { 315 | 316 | display: inline-block; 317 | width: 100%; 318 | 319 | padding: 2px 0; 320 | } -------------------------------------------------------------------------------- /elba.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vmchale/recursion_schemes" 3 | version = "0.1.0" 4 | authors = ["Vanessa McHale "] 5 | description = "A recursion schemes library for Idris" 6 | license = "BSD3" 7 | 8 | [dependencies] 9 | "vmchale/comonad" = { git = "http://github.com/vmchale/comonad" } 10 | "idris-hackers/free" = { git = "https://github.com/vmchale/idris-free" } 11 | 12 | [dev_dependencies] 13 | "git/specdris" = { git = "https://github.com/vmchale/specdris" } 14 | 15 | [targets.lib] 16 | path = "." 17 | mods = [ "Data.Functor.Foldable" 18 | , "Data.Functor.Foldable.Exotic" 19 | , "Data.Functor.Foldable.Instances" 20 | , "Data.Functor.Foldable.Mod" 21 | ] 22 | idris_opts = ["--warnreach"] 23 | 24 | [[targets.test]] 25 | name = "recursion_schemes-test" 26 | main = "Test/Spec.idr" 27 | idris_opts = ["--warnreach"] 28 | -------------------------------------------------------------------------------- /recursion_schemes.ipkg: -------------------------------------------------------------------------------- 1 | package recursion_schemes 2 | 3 | sourceloc = git://git@github.com:vmchale/recursion_schemes.git 4 | bugtracker = http://www.github.com/vmchale/recursion_schemes/issues 5 | 6 | pkgs = idris_free 7 | , comonad 8 | 9 | modules = Data.Functor.Foldable.Mod 10 | , Data.Functor.Foldable.Instances 11 | , Data.Functor.Foldable.Exotic 12 | , Data.Functor.Foldable 13 | -------------------------------------------------------------------------------- /test.ipkg: -------------------------------------------------------------------------------- 1 | package recursion_schemes 2 | 3 | sourceloc = git://git@github.com:vmchale/recursion_schemes.git 4 | bugtracker = http://www.github.com/vmchale/recursion_schemes/issues 5 | 6 | pkgs = specdris 7 | , idris_free 8 | , comonad 9 | 10 | opts = "--warnreach" 11 | 12 | modules = Data.Functor.Foldable 13 | , Data.Functor.Foldable.Instances 14 | , Data.Functor.Foldable.Exotic 15 | , Data.Functor.Foldable.Mod 16 | , Test.Spec 17 | 18 | tests = Test.Spec.specSuite 19 | --------------------------------------------------------------------------------