Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at


hpr2693 :: Getting started with web based game in Haskell and Elm

First steps in writing 4x space exploration game

<< First, < Previous, , Latest >>

Thumbnail of Tuula
Hosted by Tuula on Wednesday, 2018-11-28 is flagged as Clean and is released under a CC-BY-SA license.
haskell, yesod. 2.
The show is available on the Internet Archive at: https://archive.org/details/hpr2693

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:19:06

Haskell.

A series looking into the Haskell (programming language)

Haskell Stack: https://docs.haskellstack.org/en/stable/README/

Stack is a build tool for Haskell with focus on reproducible build plans, multi-package projects, and a consistent, easy-to-learn interface. With stack, one can create new project: stack new my-project yesod-sqlite (more in the quick start guide: https://www.yesodweb.com/page/quickstart)

models is used to define shape of the data and Yesod uses it to generate datatypes and database for you. For example, to define a Star that has name, spectral type, luminosity class and link to StarSystem, one can write:


Star json
    name Text
    starSystemId StarSystemId
    spectralType SpectralType
    luminosityClass LuminosityClass

Custom types, like LuminosityClass, need mapping between datatype and database. In simple cases like this, Yesod can do that:


data LuminosityClass = Iap | Ia | Iab | Ib | II | III | IV | V | VI | VII
    deriving (Show, Read, Eq)
derivePersistField "LuminosityClass"

The "derivePersistField" part is template haskell call that will generate mapping needed.

For those interested seeing some code, source is available at https://github.com/Tuula/deep-sky/ (https://github.com/Tuula/deep-sky/tree/baa0807dd36b61fd02174b17c10013862af4ec18 is situation before lots of Elm related changes that I mentioned in passing in the episode)


Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2018-11-30 09:07:51 by klaatu

Cool game idea, cool intro

This sounds like it would be kind of an amazing game, actually. I hope it happens. If not, it's still a neat idea.

And thanks for the taste of Haskell. I've been mildly curious about it for a while, so it's nice to hear something substantial about it.

Comment #2 posted on 2018-12-01 06:01:53 by tuturto

thanks

Thanks, I'm kind of fond of the idea too. Ideas of course are cheap and actual implementation is the tricky part. But I'm trying to get at least very minimally working system up and running at somepoint. Main idea is just to explore idea of writing such a game and learn a bit Haskell and Elm on the side.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
Who is the host of this show?
What does HPR mean to you?