clr-typed

A strongly typed Haskell interface to the CLR type system https://gitlab.com/tim-m89/clr-haskell/tree/master/libs/clr-typed

Latest on Hackage:0.2.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD-3-Clause licensed by Tim Matthews
Maintained by pepeiborra@gmail.com

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

Status

unix build statusWindows Build status

Overview

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" ()
Depends on 5 packages:
Used by 1 package:
comments powered byDisqus