Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell-like type system in C

I was wondering, is it possible to integrate haskell's powerful type system into a language like C, and still be able to do efficent low level programming?

like image 563
Ishihara Avatar asked Mar 13 '11 15:03

Ishihara


People also ask

What is the Haskell type system?

Haskell is a statically typed language. Every expression in Haskell has a type, including functions and if statements. The compiler can usually infer the types of expressions, but you should generally write out the type signature for top level functions and expressions.

What is a Haskell type class?

Haskell classes are roughly similar to a Java interface. Like an interface declaration, a Haskell class declaration defines a protocol for using an object rather than defining an object itself. Haskell does not support the C++ overloading style in which functions with different types share a common name.

Is Haskell strongly typed?

Haskell is both statically and strongly typed. However, there is no such thing as variable in Haskell so talking about dynamic or static typing makes no sense since every identifier assigned with a value cannot be changed at execution.

How do you find type in Haskell?

If you are using an interactive Haskell prompt (like GHCi) you can type :t <expression> and that will give you the type of an expression. e.g. or e.g.


2 Answers

There have been attempts to create low-level languages which use advanced type systems to make low-level programming safe. Those type systems are often actually even more advanced than Haskell's and allow things like ensuring at compile-time that pointers are accessed safely and arrays are not accessed out of bounds.

One such language is ATS (Applied Type System) which besides many of Haskell's type system features also supports linear and dependent types.

like image 183
sepp2k Avatar answered Sep 22 '22 08:09

sepp2k


I've recently stumbled upon something related:

The Habit Programming Language (lambda-the-ultimate.org)

It's a dialect of Haskell, but geared towards low-level systems programming.

like image 22
Christian Klauser Avatar answered Sep 22 '22 08:09

Christian Klauser