The ALFE type system

I want to write a series of posts about the rich type system I want to implement for ALFE. This post will serve as an index to them.

I recently tried doing a bit of programming in Haskell, and although I didn’t produce anything worth showing off, I did get a bit of a feel for the language and how it works. One of my favorite things about Haskell is the rich type system, and I want to use some of its ideas in ALFE. Some of the ALFE types below are inspired by Haskell types.

Given types Foo, Bar and Baz I would like ALFE to have the following types:

  • Foo* – a pointer type.
  • Foo(Bar) (aka Foo -> Bar) – a function type.
  • Foo | Bar – a “sum” type.
  • Foo? – a “Maybe” type.
  • (Foo, Bar) – a “product” type.
  • [Foo] – a “sequence” type.
  • Foo[2] – a fixed length array type.
  • Bottom – the “bottom” type.
  • Variant – the “variant” type.
  • Label – the “label” type.
  • Complex<Foo> – a complex number type.
  • Rational<Foo> – a rational type.
  • String – the string type (usually represented in memory as UTF-8 in some form).
  • CodePoint – a type capable of holding any Unicode code point.
  • Fixed<Foo, Bar> – a fixed point fractional type.
  • Boolean – the boolean type.
  • Int1, Int2, Int4, Int8, Byte, Int16, Int32, Int64, Int128, Int256, Int512, UInt1, UInt2, UInt4, UInt8, UByte, UInt16, UInt32, UInt64, UInt128, UInt256, UInt512, NInt1, NInt2, NInt4, NInt8, NByte NInt16, NInt32, NInt64, NInt128, NInt256, NInt512 – fixed-width integer types.
  • Word, Int, HalfWord, QuarterWord, DoubleWord, QuadWord, UWord, UInt, UHalfWord, UQuarterWord, UDoubleWord, UQuadWord, NWord, NInt, NHalfWord, NQuarterWord, NDoubleWord, NQuadWord, FastInt1, FastInt2, FastInt4, FastInt8, FastByte, FastInt16, FastInt32, FastInt64, FastInt128, FastInt256, FastInt512, FastUInt1, FastUInt2, FastUInt4, FastUInt8, FastUByte, FastUInt16, FastUInt32, FastUInt64, FastUInt128, FastUInt256, FastUInt512, FastNInt1, FastNInt2, FastNInt4, FastNInt8, FastNByte FastNInt16, FastNInt32, FastNInt64, FastNInt128, FastNInt256, FastNInt512 – machine-dependent integer types.
  • WordString, Integer, Unsigned – arbitrary-precision integer types.
  • Float16, Float32, Float64, Float128 – fixed-length floating-point types.
  • Float – machine-dependent floating point types.
  • Floating – arbitrary-precision floating point type.
  • Concrete (possibly also specializations like Length, Time, Area, MagneticFluxDensity etc.)

There’s still a lot about this that isn’t finalized. For example, I might use some templates to avoid having all those fixed-width and machine-dependent types.

7 Responses to “The ALFE type system”

  1. […] Reenigne blog Stuff I think about « The ALFE type system […]

  2. […] This is part of the ALFE types series. […]

  3. […] This is part of the ALFE types series. […]

  4. […] This is part of the ALFE types series. […]

  5. […] This is part of the ALFE types series. […]

  6. […] This is part of the ALFE types series. […]

  7. […] This is part of the ALFE types series. […]

Leave a Reply