Skip to content

Commit

Permalink
repository initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed May 27, 2011
0 parents commit 55aec2d
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 0 deletions.
20 changes: 20 additions & 0 deletions highc.sln
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighC", "highc\HighC.csproj", "{692B1EE2-CD80-4C93-888E-5D254CD30C8F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{692B1EE2-CD80-4C93-888E-5D254CD30C8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692B1EE2-CD80-4C93-888E-5D254CD30C8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692B1EE2-CD80-4C93-888E-5D254CD30C8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692B1EE2-CD80-4C93-888E-5D254CD30C8F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions highc/Ap.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace HighC {
public interface IAp<F> : IFunctor<F> {
_<F, B> ap<A, B>(_<F, Func<A, B>> f, _<F, A> a);
}
public static class ApExtensions {
public static Func<_<F, A>, _<F, B>> ap<F, A, B>(this IApplicative<F> F_, _<F, Func<A, B>> f) { return a => F_.ap(f, a); }
public static Func<_<F, Func<A, B>>, Func<_<F, A>, _<F, B>>> ap<F, A, B>(this IApplicative<F> F_) { return f => a => F_.ap(f, a); }
}
public abstract class Ap<F> : Functor<F>, IAp<F> {
public abstract _<F, B> ap<A, B>(_<F, Func<A, B>> f, _<F, A> a);
}
}
15 changes: 15 additions & 0 deletions highc/Applicative.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace HighC {
public interface IApplicative<F> : IAp<F> {
_<F, A> pure<A>(A a);
}
public static class ApplicativeExtensions {
public static Func<A, _<F, A>> pure<F, A>(this IApplicative<F> F_) { return a => F_.pure(a); }
}

public abstract class Applicative<F> : Ap<F>, IApplicative<F> {
public override _<F, B> map<A, B>(Func<A, B> f, _<F, A> xs) { return ap(pure(f), xs); }
public abstract _<F, A> pure<A>(A a);
}
}
14 changes: 14 additions & 0 deletions highc/Bind.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace HighC {
public interface IBind<F> : IAp<F> {
_<F, B> bind<A, B>(Func<A, _<F, B>> f, _<F, A> a);
}
public abstract class Bind<F> : Ap<F>, IBind<F> {
public abstract _<F, B> bind<A, B>(Func<A, _<F, B>> f, _<F, A> a);
}
public static class BindExtensions {
public static Func<_<F, A>, _<F, B>> bind<F, A, B>(this IBind<F> F_, Func<A, _<F, B>> f) { return a => F_.bind(f, a); }
public static Func<Func<A, _<F, B>>, Func<_<F, A>, _<F, B>>> bind<F, A, B>(this IBind<F> F_) { return f => a => F_.bind(f, a); }
}
}
14 changes: 14 additions & 0 deletions highc/Category.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HighC {
public interface ICategory<Hom> : ISemigroupoid<Hom> {
_<_<Hom, A>, A> id<A>();
}
public static class CategoryExtensions { }
public abstract class Category<Hom> : Semigroupoid<Hom>, ICategory<Hom> {
public abstract _<_<Hom, A>, A> id<A>();
}
}
15 changes: 15 additions & 0 deletions highc/Functor.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace HighC {
public interface IFunctor<F> {
_<F, B> map<A, B>(Func<A, B> f, _<F, A> a);
}
public abstract class Functor<F> : IFunctor<F> {
public abstract _<F, B> map<A, B>(Func<A, B> f, _<F, A> a);
}
public static class FunctorExtensions {
public static Func<_<F, A>, _<F, B>> map<F, A, B>(this IFunctor<F> F_, Func<A, B> f) { return a => F_.map(f, a); }
public static Func<Func<A, B>, Func<_<F, A>, _<F, B>>> map<F, A, B>(this IFunctor<F> F_) { return f => a => F_.map(f, a); }
}

}
62 changes: 62 additions & 0 deletions highc/HighC.csproj
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{692B1EE2-CD80-4C93-888E-5D254CD30C8F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>highc</RootNamespace>
<AssemblyName>highc</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Ap.cs" />
<Compile Include="Applicative.cs" />
<Compile Include="Bind.cs" />
<Compile Include="Category.cs" />
<Compile Include="Functor.cs" />
<Compile Include="Kleisli.cs" />
<Compile Include="Monad.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Semigroupoid.cs" />
<Compile Include="_.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
40 changes: 40 additions & 0 deletions highc/Kleisli.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HighC {
public class Kleisli {
private Kleisli() { }
}
public class KleisliSemigroupoid<K> : ISemigroupoid<_<Kleisli, K>> {
private IBind<K> k;
public KleisliSemigroupoid(IBind<K> binder) {
this.k = binder;
}
public _<_<_<Kleisli, K>, A>, C> compose<A, B, C>(_<_<_<Kleisli, K>, B>, C> f, _<_<_<Kleisli, K>, A>, B> g) {
var f0 = f.Value as Func<B, _<K, C>>;
var g0 = g.Value as Func<A, _<K, B>>;
return new _<Kleisli, K, A, C>(new Func<A, _<K, C>>(a => k.bind(f0, g0(a))));
}
}

public class KleisliCategory<K> : KleisliSemigroupoid<K>, ICategory<_<Kleisli, K>> {
private IMonad<K> k;
public KleisliCategory(IMonad<K> monad) : base(monad) {
this.k = monad;
}
public _<_<_<Kleisli, K>, A>, A> id<A>() {
return new _<_<_<Kleisli, K>, A>, A>(new Func<A, _<K, A>>(a => k.pure(a)));
}
}

public static class KleisliExtensions {
public static KleisliSemigroupoid<K> kleisli<K>(this IBind<K> bind) {
return new KleisliSemigroupoid<K>(bind);
}
public static KleisliCategory<K> kleisli<K>(this IMonad<K> monad) {
return new KleisliCategory<K>(monad);
}
}
}
14 changes: 14 additions & 0 deletions highc/Monad.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace HighC {
public interface IMonad<F> : IApplicative<F>, IBind<F> { }
public static class MonadExtensions { }
public abstract class Monad<F> : IBind<F>, IApplicative<F> {
public _<F, B> map<A, B>(Func<A, B> f, _<F, A> xs) { return bind(x => pure(f(x)), xs); }
public _<F, B> ap<A, B>(_<F, Func<A, B>> ff, _<F, A> fa) {
return bind(f => map(f, fa), ff);
}
public abstract _<F, A> pure<A>(A a);
public abstract _<F, B> bind<A, B>(Func<A, _<F, B>> f, _<F, A> a);
}
}
36 changes: 36 additions & 0 deletions highc/Properties/AssemblyInfo.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("highc")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("highc")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("093a752d-916d-4194-a6be-10e35a17a8af")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
18 changes: 18 additions & 0 deletions highc/Semigroupoid.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace HighC {
public interface ISemigroupoid<Hom> {
_<_<Hom, A>, C> compose<A, B, C>(_<_<Hom, B>, C> f, _<_<Hom, A>, B> g);
}
public abstract class Semigroupoid<Hom> : ISemigroupoid<Hom> {
public abstract _<_<Hom, A>, C> compose<A, B, C>(_<_<Hom, B>, C> f, _<_<Hom, A>, B> g);
}
public static class SemigroupoidExtensions {
public static Func<_<_<Hom, A>, B>, _<_<Hom, A>, C>> compose<Hom, A, B, C>(this Semigroupoid<Hom> Hom_, _<_<Hom, B>, C> f) {
return g => Hom_.compose(f, g);
}
public static Func<_<_<Hom, B>, C>, Func<_<_<Hom, A>, B>, _<_<Hom, A>, C>>> compose<Hom, A, B, C>(this Semigroupoid<Hom> Hom_) {
return f => g => Hom_.compose(f, g);
}
}
}
26 changes: 26 additions & 0 deletions highc/_.cs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;

namespace HighC {
public class _<F,A> {
private object value;
public _(object value) { this.value = value; }
public object Value { get { return value; } }
public override string ToString() {
return value.ToString();
}
}

public class _<F, A, B> : _<_<F, A>, B> {
public _(object value) : base(value) {}
}

public class _<F, A, B, C> : _<_<_<F, A>, B>, C> {
public _(object value) : base(value) {}
}

public class _<F, A, B, C, D> : _<_<_<_<F, A>, B>, C>, D> {
public _(object value) : base(value) { }
}


}

0 comments on commit 55aec2d

Please sign in to comment.