I feel like I should elaborate on my usecase a little bit more. The arcitecture of my game engine is that there's a hypothetical giant struct that contains all of your game data, and then there's a giant pure function that takes an input state and the previous game state, and gives you the game state for the new frame.<br><br>The problem is that writing a big function like that is a bit unwieldly, so I had the idea of separating each part out into a tiny script containing a pure function. My initial idea was that if I could strip out the io and os modules from the environment, each lua module (file) would be considered pure as a whole. <br><br>So this type system was designed such that I could:<br>Get a value of a type -> Convert it to lua types -> call lua code with it -> Convert into my type system -> Type check the result<br><br>I don't know if I needed the TypedValue; but I felt it was convenient for a value to carry around it's type for some reason, my (in foresight flawed) vision was that lua code would call into haskell code, and I would keep on type checking in the interim, but I now realize that I don't need to do that if I'm checking at the end anyways.<br><br>Now that you mention it, implementing my own statically typed language would probably be better than trying to rig a strict type system on a traditionally dynamically typed language. I have to think about this for a little bit.<br><br>Thank you for the notes, I'll be looking them over. <br><br><br>-------- Original Message --------<br>On Jul 10, 2023, 7:01 PM, Brent Yorgey < byorgey@gmail.com> wrote:<blockquote class="protonmail_quote"><br><div dir="ltr">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: <a href="https://hendrix-cs.github.io/csci360/">https://hendrix-cs.github.io/csci360/</a><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>-Brent</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 10, 2023 at 7:36 AM Talha Qamar via Haskell-Cafe <<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>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.<br><br>Long story short, how would I represent a type system in Haskell? I've gotten _something_ together that works a bit like this:<br><br>```<br>data Type = -- ...all possible types<br>data Value = -- ...all possible types again<br>data TypedValue = TypedValye Type Value<br>```<br>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.<br><br>Any help would be appreciated.<br><br>Sent from Proton Mail mobile<br><br><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
</div>