[Haskell-cafe] Representing a type system in Haskell

Brent Yorgey byorgey at gmail.com
Mon Jul 10 14:01:26 UTC 2023


So to make sure I'm understanding correctly, you want to create your own
statically typed scripting language for your game engine?  Implementing
your own statically-typed language is definitely a fun and worthwhile
learning experience.  You might find helpful the notes from my programming
languages course, which is taught in Haskell:
https://hendrix-cs.github.io/csci360/

Having `Type` and `Value` ADTs to represent types and values makes sense.
They often do correspond closely since there is often a canonical kind of
value for each type, but they are not necessarily exactly the same.

You didn't mention an ADT for expressions/terms, i.e. syntax.  Typically
you will parse concrete syntax to produce a Term, and then you will
typecheck a Term to make sure it has a valid Type.  Then you can interpret
the Term to produce a Value.

I am not sure what the point of TypedValue is.  Typically, once you are
finished with typechecking, you no longer need to keep track of types while
interpreting.

-Brent

On Mon, Jul 10, 2023 at 7:36 AM Talha Qamar via Haskell-Cafe <
haskell-cafe at haskell.org> wrote:

>
> Hello everyone, I'm working on a game engine in Haskell. The thing is,
> while I want to write the architecture in Haskell, I'm thinking of using
> something else as the actual scripting language.
>
> Long story short, how would I represent a type system in Haskell? I've
> gotten _something_ together that works a bit like this:
>
> ```
> data Type = -- ...all possible types
> data Value = -- ...all possible types again
> data TypedValue = TypedValye Type Value
> ```
> But I'm concerned if this is the ideal way of doing things, particularly
> when I get to complex types like structs or tagged unions.
>
> Any help would be appreciated.
>
> Sent from Proton Mail mobile
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20230710/1a92e286/attachment.html>


More information about the Haskell-Cafe mailing list