
Show HN: Tic Tac Toe Implemented in Elm - vishaltelangre
https://vishaltelangre.com/tic-tac-toe
======
speps
I did a few games with Elm but used the SVG route myself. It's usually a lot
easier to work with and you don't really have to deal with CSS and the DOM
update is still lazy.

Finally, I think there are a few red flags in your code. For example you have
a hardcoded list of cell locations but you use a method to compute the number
of rows which has a sqrt in it... might as well hardcode the number of rows :)

~~~
fiatjaf
Is the code for these games available? I've never programmed a game before, I
want to do it. Maybe doing it in Elm will be a good idea.

~~~
AnkhMorporkian
I don't mean to be a naysayer, but if you want to program a real game, Elm
really isn't the language to do it in. Perhaps at some point in the future
it'll be a language to watch, but there are far better options available right
now, even if you want to stay functional.

------
edejong
I'm slightly surprised that a simple tic-tac-toe game in high-level FP takes
400 lines of code.

~~~
kqr
Not sure how you reached that number. The Elm code, with blank lines removed,
is less than 320 lines. Given the incredibly spacious style its written in,
I'd definitely say 300 rather than 400.

But sure, that's still a lot. Part of it is that Elm lacks the proper generics
support (which you can observe in the function names) and part is that the
archotecture chosen by the creator may not be optimal in terms of
maintainability. For example,

    
    
        type Cell = NotOwned CellLocation | OwnedBy CellLocation Player
    

and I think, why not

    
    
        type Cell = Cell Location (Maybe Player)
    

? Its isomorphic (carries the same information) and it removes the need for
the complicated getters.

~~~
vishaltelangre
Yes, there are lot places I think I can optimize it. It is an initial
implementation to get something working. Thanks.

------
vishaltelangre
Source code is at [https://github.com/vishaltelangre/elm-tic-tac-
toe](https://github.com/vishaltelangre/elm-tic-tac-toe).

------
guyromm
shameless self plug: a chutes and ladders game in elm on the client, python
(flask) on the server. [https://github.com/guyromm/snakes-and-
ladders](https://github.com/guyromm/snakes-and-ladders)

------
maxraz
That was fun

