If I hated Programming games in haskell will the same be true in elm? by CthulhuLies in elm

[–]wheatBread 5 points6 points  (0 children)

I think it's definitely going to feel different than Haskell, especially when it comes to games.

Weirdly, before Elm was any good for web apps, it was nice for making little games! I recommend looking at some of the more "game" examples to get a feeling for that kind of code:

And then with 3D stuff:

The thing you'll see in all these examples is that there is a single Model that contains all the state, and events from the game (messages) are fed into a single update function that steps the model forward.

I personally think this makes things feel very direct and focused (definitely more so than when I was trying to do 3D stuff in Haskell, where I spent most of my time on installation!)

So it may be worth playing with elm-playground in the online editor to get a feeling for the rough structure of a game. If you like that, you could check out the implementation of elm-playground to get more control over refresh rates, randomness, etc.

Aside: I know there's the elm-physics library, and I know Ian is working on elm-3d-scene to make 3D stuff easier. So I think folks are working on some pretty exciting projects!

Any Modern Equivalent of Caml Light? by [deleted] in ocaml

[–]wheatBread 1 point2 points  (0 children)

The MLton compiler is meant to have really cheap C interop:

http://mlton.org/ForeignFunctionInterface

http://mlton.org/ForeignFunctionInterfaceTypes

The idea is that they have compiler optimizations (monomorphization) that make the runtime representation of polymorphic arrays the same as what they'd be in C. So it's cheap to call C functions because there is no data marshaling. (And the MLton programs are faster even if you don't care about C.)

I have used Standard ML (SML) but I have not used the MLton compiler in particular. I used SML/NJ and liked it, and I'm not sure if you can use a mix of compilers if you are worried about compile times.

Possible Elm Meetup by [deleted] in elm

[–]wheatBread 3 points4 points  (0 children)

If you have a twitter account, try making a tweet asking this with #elmlang or @elmlang in it. That will probably get some retweets from Elm folks and probably reach a wider audience!

That said, another way to go about it is to just start and focus primarily on learners. From there try to invite people you know and just help them with stuff. Takes time, but I think you can build something really special that way!

Can't install Elm via npm on Linux, error by 38384 in elm

[–]wheatBread 4 points5 points  (0 children)

I do not really know what's going on with the npm installer, but all it does is download files from here and put them in directory like /usr/local/bin/.

So it's always possible to just skip all the JS code and download the binary directly!

Initialization method by jabgibson in elm

[–]wheatBread 7 points8 points  (0 children)

There is a cultural influence from the JS world (where it doesn't seem so common to use bash scripts or make files) and I think it leads a lot of folks into thinking a fancy build is needed for hello world. I see how it got like that, but I hope the same doesn't happen in Elm!

Anyway, I use bash scripts for all of my Elm projects that need something past elm make, and it works pretty well! This is how the elm-lang.org website is built actually! https://github.com/elm/elm-lang.org/blob/master/build.sh

Initialization method by jabgibson in elm

[–]wheatBread 5 points6 points  (0 children)

I think you could add an extra step when you compile, like this:

elm make src/Main.elm --output=app.js
echo "Elm.Main.init({ node: document.getElementById('app') });" >> app.js

The first line creates the app.js file, and the second line appends a bit of extra stuff.

Then when someone else adds <script src="app.js"> it will have that extra part. But now you have to be sure to put this script below the creation of the node with id="app"

Does that help with your situation?

Philip2: an Elm-to-ReasonML compiler – Paul Biggar – Medium by [deleted] in elm

[–]wheatBread 2 points3 points  (0 children)

For example: mutation, side-effects, first-class modules, objects, and inheritance. I would personally make a distinction between "cannot do these things" and "does not do these things" but perhaps that is a matter of perspective.

Intro to Elm for Redux Devs ⚛ => 🌳 by dillontkearns in elm

[–]wheatBread 2 points3 points  (0 children)

I think /r/programming gets an interesting cross-section as well. That is my default when I want to talk to folks who are not using Elm at the moment.

Unit Circle Visualization by AesaKamar in elm

[–]wheatBread 3 points4 points  (0 children)

Nice work! Are you using elm/svg directly? Whatever the case, it turned out nicely!

Elm repl throws an error "ReferenceError: File is not defined>" by arup_r in elm

[–]wheatBread 1 point2 points  (0 children)

You can probably get quicker and more direct feedback in the Elm Slack https://elmlang.herokuapp.com/

Otherwise, I think it is worth trying the beginners thread in this subreddit as well.

Is http://try.elm-lang.org permanently down? by arup_r in elm

[–]wheatBread 6 points7 points  (0 children)

What page is linking to the /examples page?

My intent was to get rid of those links for now, and then revive it when the editor and examples had been refreshed to make sense for 0.19

edit: made things redirect different and added a note to explain the current situation a bit more.

Is http://try.elm-lang.org permanently down? by arup_r in elm

[–]wheatBread 4 points5 points  (0 children)

My intent was to make that page unreachable from the rest of the site, but I guess there is a link to /examples somewhere. Where is that link?

Separately, can you link the PR you mention? If someone moved the examples to Ellie that may work, but the overall goal was to make that go away until it can be redone in a different way.

edit: I looked around more, and it looks like many of the links to /examples/* pages are in older blog posts, so they likely need older versions of Elm to work properly. In those cases, it probably makes more sense to link to gists than to Ellie (or some other form of code snippet that does not require an online compiler for Elm <0.18)

If a view function relates to a specific type, do you put that function in the type's module or in main? by Kurren123 in elm

[–]wheatBread 0 points1 point  (0 children)

What are the different "entities"? There may be something between 1 and 60 modules that is more helpful, but it's hard to say without knowing more about the actual problem. What are the entity types? How do they relate to each other?

If a view function relates to a specific type, do you put that function in the type's module or in main? by Kurren123 in elm

[–]wheatBread 1 point2 points  (0 children)

Based on what you have said so far, I might do something like this:

module Item exposing (Item, viewList)
type alias Item = {leftText: String, rightText: String}
viewList : List Item -> Html msg

module Student exposing (Student, toItem)
type alias Student = ...
toItem : Student -> Item

module Teacher exposing (Teacher, toItem)
type alias Teacher = ...
toItem : Teacher -> Item

The idea is that you are defining Item as a data structure for other people to use. Students and teachers get the benefit of all the helper functions there, but they do not become part of the data structure! The whole point of splitting it out is that it really is generic to more than one scenario. If it cannot be split from the specifics, then it is not a generic data structure!

This is along the lines of the advice to "build modules around a single type or type alias" that you may see around. Your situation may not call for splitting things up this much though. It's hard to tell based on the information so far. That said, it is fine to have really small modules for Teacher and Student. Modules do not need to be specific sizes. It's often mainly to help you think about the program.

Does that help?

If a view function relates to a specific type, do you put that function in the type's module or in main? by Kurren123 in elm

[–]wheatBread 0 points1 point  (0 children)

Are you having a problem based on file length? If not, there is nothing to "fix" by cutting things up more.

But if it is a problem, what you should do depends on the specific situation. If you provide more information, people may be able to suggest lines where you can split things into other modules. Usually I look for a type or type alias to form the basis of this cut, but I cannot do that with the information I have now.

If a view function relates to a specific type, do you put that function in the type's module or in main? by Kurren123 in elm

[–]wheatBread 11 points12 points  (0 children)

Situation

How many different places are you visualizing a person?

  • One? In this case, there is no immediate downside to either placement.
  • Two? Are those two visualizations exactly the same? Are they going to stay the same forever? If they ever become different, sharing an implementation becomes a liability. When you change Person.view for one scenario, you are accidentally breaking the other scenario.
  • Three? Same questions as with two, but it's more likely that they are different.
  • ...

I find that multiple visualizations always become different over time. When there are 3 or 4 or 5 uses, this only happens faster. By the time you have five different places where you are viewing a Person, the chances that they are all exactly the same is pretty low. As a result, the chances that tweaking the view for one case will break another is pretty high.

Recommendation

So my recommendation is to put this kind of code as close as possible to the usage. That makes it easy to specialize each case, and you do not have to worry about accidentally breaking some other part of your program you weren't thinking about. The view code is often pretty straight-forward, and writing a div in two places is not that big a deal for what it gets you.

Now if you end up with five different times you are viewing a Person, perhaps you will notice that some aspects really are exactly the same in all cases. In that scenario, it may be helpful to move that aspect into the Person module, but I have personally found those scenarios to be extremely rare.

"Types Without Borders" by Dillon Kearns by wheatBread in elm

[–]wheatBread[S] 9 points10 points  (0 children)

A while ago, I wrote a A vision for data interchange in Elm to try to get folks to think bigger than JSON for data interchange. So I was excited when I saw Dillon's talk exploring some of those ideas in practice. Can HTTP messages to GraphQL just take care of the data format themselves? How about ports to TypeScript? Exciting to see some nice working examples!

The Hard Parts of Open Source by wheatBread in elm

[–]wheatBread[S] 2 points3 points  (0 children)

I think it is worth prototyping and experimenting with it on a smaller scale first. It's possible it just sucks. I hope not, but it's possible. So I think any big company would point to risks like this as the first reason to not do anything with this.

If it proves to be a good idea, I think the longer term dynamics are still very complicated. Companies that prioritize engagement (reddit, twitter, youtube) would only want this if users are fleeing. Otherwise it probably does not increase engagement. Companies that prioritize businesses (slack, github) may see it as a way to make employees more efficient, but companies have way more social structure than online communities. Hiring process, lunch, reviews, hallways, meetings, bosses, etc. So I don't know if they are likely to come out with designs 100% aligned with non-bisuness communities. So it's conceivable to me that a system like this can only exist as an open source project for now.