├── src └── Higher │ ├── paket.references │ ├── Algebra.fs │ ├── MonadTrans.fs │ ├── Category.fs │ ├── Applicative.fs │ ├── App.config │ ├── Traversable.fs │ ├── Flip.fs │ ├── PerfectTree.fs │ ├── Option.fs │ ├── Const.fs │ ├── Tuple.fs │ ├── paket.template │ ├── Choice.fs │ ├── Fun.fs │ ├── Yoneda.fs │ ├── Seq.fs │ ├── Cont.fs │ ├── Free.fs │ ├── Writer.fs │ ├── Arrow.fs │ ├── Fix.fs │ ├── RightKan.fs │ ├── Reader.fs │ ├── Index.fs │ ├── State.fs │ ├── Codensity.fs │ ├── ListT.fs │ ├── CoYoneda.fs │ ├── LeftKan.fs │ ├── Compose.fs │ ├── Leibniz.fs │ ├── OptionT.fs │ ├── FTLens.fs │ ├── Kleisli.fs │ ├── ContT.fs │ ├── Adjunction.fs │ ├── List.fs │ ├── WriterT.fs │ ├── ReaderT.fs │ ├── Cofree.fs │ ├── Monoid.fs │ ├── Comonad.fs │ ├── StateT.fs │ ├── Functor.fs │ ├── FFree.fs │ ├── Monad.fs │ ├── Identity.fs │ ├── Script.fsx │ ├── CoreTypes.fs │ ├── Coproduct.fs │ └── Higher.fsproj ├── RELEASE_NOTES.md ├── tests └── Higher.Tests │ ├── paket.references │ ├── Tests.fs │ ├── App.config │ ├── ListF.fsx │ └── Higher.Tests.fsproj ├── docs ├── files │ └── img │ │ ├── logo.png │ │ └── logo-template.pdn ├── content │ ├── tutorial.fsx │ └── index.fsx └── tools │ ├── templates │ └── template.cshtml │ └── generate.fsx ├── .paket ├── paket.bootstrapper.exe └── paket.targets ├── .travis.yml ├── appveyor.yml ├── paket.dependencies ├── lib └── README.md ├── .gitattributes ├── .github └── ISSUE_TEMPLATE.md ├── README.md ├── paket.lock ├── Higher.sln ├── .gitignore └── LICENSE.txt /src/Higher/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.Core -------------------------------------------------------------------------------- /RELEASE_NOTES.md: -------------------------------------------------------------------------------- 1 | #### 1.0 - October 17 2016 2 | * Initial release 3 | -------------------------------------------------------------------------------- /tests/Higher.Tests/paket.references: -------------------------------------------------------------------------------- 1 | FSharp.Core 2 | group Test 3 | NUnit 4 | NUnit.Runners -------------------------------------------------------------------------------- /docs/files/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palladin/Higher/HEAD/docs/files/img/logo.png -------------------------------------------------------------------------------- /.paket/paket.bootstrapper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palladin/Higher/HEAD/.paket/paket.bootstrapper.exe -------------------------------------------------------------------------------- /docs/files/img/logo-template.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/palladin/Higher/HEAD/docs/files/img/logo-template.pdn -------------------------------------------------------------------------------- /src/Higher/Algebra.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | type Algebra<'F, 'A> = App<'F, 'A> -> 'A 4 | 5 | type CoAlgebra<'F, 'A> = 'A -> App<'F, 'A> 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | 3 | sudo: false # use the new container-based Travis infrastructure 4 | 5 | before_install: 6 | - chmod +x build.sh 7 | 8 | script: 9 | - ./build.sh All 10 | -------------------------------------------------------------------------------- /src/Higher/MonadTrans.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | /// Monad Transformer Class 4 | [] 5 | type MonadTrans<'MT>() = 6 | abstract Lift<'M, 'T> : Monad<'M> -> App<'M, 'T> -> App2<'MT, 'M, 'T> 7 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | init: 2 | - git config --global core.autocrlf input 3 | build_script: 4 | - cmd: build.cmd All 5 | test: off 6 | version: 0.0.1.{build} 7 | artifacts: 8 | - path: bin 9 | name: bin 10 | -------------------------------------------------------------------------------- /src/Higher/Category.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | /// Category Class 4 | [] 5 | type Category<'F>() = 6 | abstract Ident<'A> : unit -> App2<'F, 'A, 'A> 7 | abstract Compose<'A, 'B, 'C> : App2<'F, 'A, 'B> -> App2<'F, 'B, 'C> -> App2<'F, 'A, 'C> 8 | -------------------------------------------------------------------------------- /src/Higher/Applicative.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | /// Applicative Class 4 | [] 5 | type Applicative<'F>() = 6 | inherit Functor<'F>() 7 | override self.Map f func = 8 | self.Apply (self.Pure f) func 9 | abstract Pure<'T> : 'T -> App<'F, 'T> 10 | abstract Apply<'T, 'R> : App<'F, 'T -> 'R> -> App<'F, 'T> -> App<'F, 'R> 11 | -------------------------------------------------------------------------------- /paket.dependencies: -------------------------------------------------------------------------------- 1 | source https://nuget.org/api/v2 2 | 3 | nuget FSharp.Core redirects: force 4 | 5 | group Build 6 | source https://nuget.org/api/v2 7 | 8 | nuget SourceLink.Fake 9 | nuget FAKE 10 | nuget FSharp.Formatting 11 | 12 | github fsharp/FAKE modules/Octokit/Octokit.fsx 13 | 14 | group Test 15 | source https://nuget.org/api/v2 16 | 17 | nuget NUnit ~> 2 18 | nuget NUnit.Runners ~> 2 -------------------------------------------------------------------------------- /docs/content/tutorial.fsx: -------------------------------------------------------------------------------- 1 | (*** hide ***) 2 | // This block of code is omitted in the generated HTML documentation. Use 3 | // it to define helpers that you do not want to show in the documentation. 4 | #I "../../bin" 5 | 6 | (** 7 | Introducing your project 8 | ======================== 9 | 10 | Say more 11 | 12 | *) 13 | #r "Higher.dll" 14 | open Higher 15 | 16 | Library.hello 0 17 | (** 18 | Some more info 19 | *) 20 | -------------------------------------------------------------------------------- /lib/README.md: -------------------------------------------------------------------------------- 1 | This file is in the `lib` directory. 2 | 3 | Any **libraries** on which your project depends and which are **NOT managed via NuGet** should be kept **in this directory**. 4 | This typically includes custom builds of third-party software, private (i.e. to a company) codebases, and native libraries. 5 | 6 | --- 7 | NOTE: 8 | 9 | This file is a placeholder, used to preserve directory structure in Git. 10 | 11 | This file does not need to be edited. 12 | -------------------------------------------------------------------------------- /tests/Higher.Tests/Tests.fs: -------------------------------------------------------------------------------- 1 | module Higher.Tests 2 | 3 | open NUnit.Framework 4 | 5 | [] 6 | let ``Cathegory function``() = 7 | // Arrange 8 | let f = Fun.Inj (fun x -> x + 1) 9 | let g = Fun.Inj (fun (x : int) -> string x) 10 | let category = new FunCategory() 11 | 12 | // Act 13 | let h = category.Compose f g 14 | let actual = Fun.Prj h 1 15 | 16 | // Assert 17 | let expected = "2" 18 | Assert.AreEqual(expected, actual) 19 | -------------------------------------------------------------------------------- /src/Higher/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | True 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/Higher.Tests/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | True 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Higher/Traversable.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | /// Traversable Class 4 | [] 5 | type Traversable<'TR>() = 6 | inherit Functor<'TR>() 7 | abstract Traverse<'F, 'T, 'R> : Applicative<'F> -> ('T -> App<'F, 'R>) -> App<'TR, 'T> -> App<'F, App<'TR, 'R>> 8 | override self.Map<'T, 'R> (f : 'T -> 'R) (func : App<'TR, 'T>) : App<'TR, 'R> = 9 | Identity.Run <| self.Traverse (new IdentityApplicative()) (Identity.Inj << Id << f) func 10 | member self.SequenceA applicative trav = 11 | self.Traverse applicative id trav 12 | -------------------------------------------------------------------------------- /src/Higher/Flip.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | type Flip<'F, 'A, 'B> = F of App2<'F, 'B, 'A> 4 | 5 | type Flip private () = 6 | static let token = new Flip() 7 | static member Inj (value : Flip<'F, 'A, 'B>) : App3 = 8 | App3.Create(AppToken2.Token(token), value) 9 | static member Prj (app3 : App3) : Flip<'F, 'A, 'B> = 10 | app3.Apply(AppToken2.Token(token)) :?> _ 11 | static member Run (app3 : App3) : App2<'F, 'B, 'A> = 12 | let (F app) = Flip.Prj app3 in app 13 | -------------------------------------------------------------------------------- /src/Higher/PerfectTree.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | // Source 4 | // https://github.com/ocamllabs/higher/blob/master/examples/example-1-perfect-trees.ml 5 | 6 | type Perfect<'T> = 7 | | Zero of 'T 8 | | Succ of Perfect<'T * 'T> 9 | 10 | 11 | type PerfectFolder<'F> = 12 | abstract Zero<'T> : 'T-> App<'F, 'T> 13 | abstract Succ<'T> : App<'F, 'T * 'T> -> App<'F, 'T> 14 | 15 | 16 | module Perfect = 17 | let rec foldP<'F, 'T> : PerfectFolder<'F> -> Perfect<'T> -> App<'F, 'T> = fun phi p -> 18 | match p with 19 | | Zero v -> phi.Zero v 20 | | Succ p -> phi.Succ (foldP phi p) 21 | -------------------------------------------------------------------------------- /src/Higher/Option.fs: -------------------------------------------------------------------------------- 1 | namespace Higher 2 | 3 | /// Option Monad type 4 | type Option private () = 5 | static let token = new Option() 6 | static member Inj (value : 'T option) : App = 7 | App<_, _>.Create(token, value) 8 | static member Prj (app : App) : 'T option = 9 | app.Apply(token) :?> _ 10 | 11 | /// Option Monad instance 12 | type OptionMonad() = 13 | inherit Monad