Question

For example, in Java there is Functional Java and Higher-Order Java. Both essentially give a small API for manipulating higher-order, curried functions, and perhaps a few new data types (tuples, immutable lists).

Was it helpful?

Solution

have you looked into F#?

Also a neat blog post would be here that talks about how to use the new generic / lambda expressions built into c# 3.0.

If you just add using System.Linq to the top of your source file there are a LOT of nice new functions added to working with collections such as folding / filtering / etc.

OTHER TIPS

LanguageExt looks very promising for making functional style programming in C# easier.

https://github.com/louthy/language-ext

Assuming you can't use F# for whatever reason, and just want to use functional paradigms and idioms in your C# code to improve quality & reliability:

Functional style pattern matching for C#

Monad library for C#/.Net

There is also 'elevate' which has some functional things like option types (maybes) etc.

I think you want F#

Also, the more recent versions of C# have a lot of functional concepts included in the base langauge.

There may be such a library for C#, but you should probably consider just using F# http://research.microsoft.com/fsharp/fsharp.aspx and http://msdn.microsoft.com/en-us/fsharp/default.aspx.

Microsoft plans to make F# a first-class language in Visual Studio so there should be little risk in using one of the CTPs to build your initial stuff.

If you're looking for something that extends C# then no, but there is F# which is a .NET based functional language. From the "About F#" page:

F# is a typed functional programming language for the .NET Framework. It combines the succinctness, expressivity, and compositionality of typed functional programming with the runtime support, libraries, interoperability, tools and object model of .NET. F# stems from the ML family of languages and has a core language compatible with that of OCaml, though also draws from C# and Haskell. F# was designed from the ground up to be a first-class citizen on .NET, giving smooth interoperability with other .NET languages. For example, C# and F# can call each other directly. This means that F# has immediate access to all the .NET Framework APIs, including, for example, Windows Presentation Foundation and DirectX. Similarly, libraries developed in F# may be used from other .NET languages.

Since F# and OCaml share a similar core language, some OCaml libraries and applications can cross-compile either directly or with minor conditionally-compiled changes. This provides a path to cross-compile and/or port existing OCaml code to .NET, and also allows programmers to transfer skills between these languages. A major focus of the project has been to extend the reach of OCaml-like languages into arenas where they have not traditionally been used. Throughout the project the designers of F# are grateful for the support and encouragement of Xavier Leroy and others in the OCaml community.

Not a shrink-wrapped library per se, but Luca Bolognese of Microsoft has a series of blog posts where he builds a C# library for functional programming with types like tuples, records, type unions and so on:

Also Linq is basically a library for functional programming with syntactial support in C#.

F#, there's a CTP release available from microsoft.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top