clr-typed: A strongly typed Haskell interface to the CLR type system

[ .net, bsd3, clr, ffi, language, library ] [ Propose Tags ]
Versions [RSS], 0.2.0
Dependencies base (>=4.7 && <5), clr-marshal, ghc-prim, text, tuple [details]
License BSD-3-Clause
Copyright Copyright: (c) 2016-2017 Tim Matthews
Author Tim Matthews
Category Language, FFI, CLR, .NET
Home page
Bug tracker
Source repo head: git clone
Uploaded by PepeIborra at 2017-08-05T09:02:39Z
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 1842 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-08-05 [all 1 reports]

Readme for clr-typed-0.2.0

[back to package description]

clr-typed - A strongly typed Haskell interface to the CLR type system


unix build statusWindows Build status


This package provides a library to implement a strongly typed flavour for CLR <-> Haskell interoperability. It includes an encoding of OOP type system semantics within the GHC Haskell type system.

See the example for what it is currently capable of and how to use it.

What it looks like

  • CLR member & type names are specified with a type level Symbol, and are expected to be applied via the TypeApplications extension.
  • Arguments are tupled, so that overload resolution can see the full type up front. Unit is used for argument-less methods.
  • Method identifier comes first due to type applications.
resulta <- invokeI @"ObjMethodName" object ()  -- No arguments
resultb <- invokeI @"ObjMethodName" object "arg0"
resultc <- invokeI @"ObjMethodName" object ("arg1", 3, "hi")

  • Similarly for static methods. Method identifier again comes first for consistency with instance methods.
invokeS @"DoStuff" @"SomeClass" ()
  • Constructors are used in a similar fashion
obj <- new @"SomeType" ()
  • Generic type instantiations are done using a promoted tuple instead of just a Symbol
strList <- new @'("List", "String") ()
  • Generics may be used in a method identifier position in the same way
invokeS @'("SomeGenericMethod", "Integer") @"SomeClass" ()