recipe wiki

191 views
Skip to first unread message

Alexandre Rousseau

unread,
Jul 9, 2015, 10:56:44 AM7/9/15
to elm-d...@googlegroups.com
I wish for a cookbook/wiki, filled with user-contributed snippets of Elm code that address specific needs, also allowing users to add to a wish list and/or contribute their own.

OTOH, Elm's current Examples page is a cookbook of sorts. To contribute, one just needs to add to the repository and make a pull request. Not very user friendly but this is Elm, not HoldMyHands++; I assume most people here are comfortable with git.

Thoughts?

Until then, I'll keep the snippets I create on my side and think of contributing to https://github.com/elm-lang/elm-lang.org from time to time.

BTW, here's what I have so far:

Recipe: fill browser window with a circle
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Color
import Signal
import Window


circle
: (Int, Int) -> Element
circle
(w, h) =
  let
    padding
= 5
    rad
= toFloat (min w h) - padding
 
in
    collage w h
     
[
        oval rad rad
       
|> filled Color.red
     
]
     
main
: Signal Element
main
=
 
Signal.map circle Window.dimensions




Recipe: Mouse click to transition between states
import Graphics.Element exposing (..)

import Signal
import Mouse
import Graphics.Collage exposing (..)
import Color


-- States and transitions
type
GameState = Intro | Play | GameOver | UnknownState


next : GameState -> GameState
next state =
 
case state of
   
Intro -> Play
   
Play -> GameOver
   
GameOver -> Intro
    _
-> UnknownState


-- Rendering
render
: GameState -> Element
render state
=
 
case state of
   
Intro -> collage 100 100 [ rect 100 100 |> filled Color.lightBlue ]
   
Play -> collage 100 100 [ rect 100 100 |> filled Color.green ]
   
GameOver -> collage 100 100 [ rect 100 100 |> filled Color.red ]
    _
-> show "Unknown state"
 
-- main
main
: Signal Element
main
=
 
Signal.map render (Signal.foldp (\click state -> next state) Intro Mouse.clicks)




Texas Toland

unread,
Jul 9, 2015, 11:38:34 AM7/9/15
to elm-d...@googlegroups.com
I wish for a cookbook/wiki, filled with user-contributed snippets of Elm code that address specific needs, also allowing users to add to a wish list and/or contribute their own.

Strongly agree! We had something like this (https://github.com/robotlegs/robotlegs-demos-Bundle) on a MVC I worked on which was superb. Basically each folder contains someone's sample app. I think good criteria would be anything 1) that runs, 2) not duplicate, 3) not offensive, and 4) <1 MB (because many projects would be aggregated in one place). An alternative would be an "awesome list" (https://github.com/sindresorhus/awesome) of such projects. That's what Brunch does (http://brunch.io/skeletons.html). Preference? Alternative? 

Alexandre Rousseau

unread,
Jul 9, 2015, 12:14:32 PM7/9/15
to elm-d...@googlegroups.com
Interesting suggestions and a good question: with or without content moderation. With requires effort from the repository owner. Stuff already exists, such as http://stackoverflow.com/questions/tagged/elm and https://gist.github.com/search?l=elm&q=elm . I'm just not sure which way to go but I am sure that snippet sharing would boost learning and cut development time for everyone who made use of such a tool.

On Thu, Jul 9, 2015 at 11:38 AM, Texas Toland <te...@appship.it> wrote:
I wish for a cookbook/wiki, filled with user-contributed snippets of Elm code that address specific needs, also allowing users to add to a wish list and/or contribute their own.

Strongly agree! We had something like this (https://github.com/robotlegs/robotlegs-demos-Bundle) on a MVC I worked on which was superb. Basically each folder contains someone's sample app. I think good criteria would be anything 1) that runs, 2) not duplicate, 3) not offensive, and 4) <1 MB (because many projects would be aggregated in one place). An alternative would be an "awesome list" (https://github.com/sindresorhus/awesome) of such projects. That's what Brunch does (http://brunch.io/skeletons.html). Preference? Alternative? 

--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/hdKyIsAjnR4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Max Goldstein

unread,
Jul 9, 2015, 12:41:10 PM7/9/15
to elm-d...@googlegroups.com
I think this could live in the same repo as the roadmap from the other thread. I think we should try self-moderation and make a new plan if that doesn't work. It would be understood that the examples are communal, and anyone with access can improve them.

Alexandre Rousseau

unread,
Jul 9, 2015, 12:43:07 PM7/9/15
to elm-d...@googlegroups.com
Would you care to make a first (sample) contrib? I'd follow suit after that. :)

On Thu, Jul 9, 2015 at 12:41 PM, Max Goldstein <maxgol...@gmail.com> wrote:
I think this could live in the same repo as the roadmap from the other thread. I think we should try self-moderation and make a new plan if that doesn't work. It would be understood that the examples are communal, and anyone with access can improve them.

--

Texas Toland

unread,
Jul 9, 2015, 12:47:50 PM7/9/15
to elm-d...@googlegroups.com
I think this could live in the same repo as the roadmap from the other thread.

Agreed.

anyone with access can improve them.

It still needs to be by PR but anyone with access can merge.

Would you care to make a first (sample) contrib? I'd follow suit after that. :)

I'll ask Evan directly and create it this weekend with his approval or any addenda. Great suggestion!

Alexandre Rousseau

unread,
Jul 9, 2015, 10:58:16 PM7/9/15
to elm-d...@googlegroups.com
It would be understood that the examples are communal, and anyone with access can improve them.

This makes sense to me provided that improvements prioritize, in that order:
1. bug fixes
2. greater clarity
3. performance improvements

and avoid clever terseness at all cost (unless the recipe is for terseness).

A.

Max Goldstein

unread,
Jul 9, 2015, 11:58:08 PM7/9/15
to elm-d...@googlegroups.com
1. bug fixes
2. greater clarity
3. performance improvements

2.33 More idiomatic code
2.67 Code that does more interesting things (without losing too much simplicity)

The best examples can be merged back into the website.

Bryan Muir

unread,
Jul 10, 2015, 10:39:41 AM7/10/15
to elm-d...@googlegroups.com
Can we also add what version of ELM they are made to run against?

I've run into a bunch of code on the web and in print that no longer works because the language has evolved..

Texas Toland

unread,
Jul 10, 2015, 11:13:55 AM7/10/15
to elm-d...@googlegroups.com
Can we also add what version of ELM they are made to run against?

Each project will be required to be runnable including the package file listing all versions.

Max Goldstein

unread,
Jul 10, 2015, 11:39:12 AM7/10/15
to elm-d...@googlegroups.com
Each project will be required to be runnable including the package file listing all versions.

Sure, although simple demos that rely only on core can go in the same folder. (Right?)

Texas Toland

unread,
Jul 10, 2015, 11:53:58 AM7/10/15
to elm-d...@googlegroups.com
same folder. (Right?)

Same folder as one another? I suppose if they could be run from the same main.

simple demos that rely only on core

Core and Elm itself are still versioned and code that can't be verified to be correct or otherwise useful just adds to the burden of support the list is already fielding. It seems like most of the questions have to do with building practical things anyway?

Texas Toland

unread,
Jul 20, 2015, 1:55:07 PM7/20/15
to elm-d...@googlegroups.com
This is top of my todo this week! My plan is to create a master elm-expo project that contains helpful example apps. Evan's tutorialHassan's checkerboard, and elmchat from the blogosphere are the initial candidates I'm familiar with. I'd appreciate more recommendations? If you're git savvy, I'll be using subtree to aggregate external projects in a way that's invisible to anyone cloning (unlike submodules) but can still merge updates from source repos. I'll transfer repo ownership to elm-lang when it's automatic enough to not create support for Evan. I'll think about a way to automatically host them in the future.

trotha01

unread,
Jul 30, 2015, 1:10:49 AM7/30/15
to Elm Discuss, te...@appship.it
Was a repo ever created for this?
I would love to look at further examples, and hopefully add a few as well.

Texas Toland

unread,
Jul 30, 2015, 1:23:39 AM7/30/15
to trotha01, Elm Discuss
> Was a repo ever created for this?

I started working on the Sublime plugin first because of lack of feedback. I think it's an afternoon project including a Bash script to make it easy to accept and update contributions by other maintainers. I should have time this weekend though.

trotha01

unread,
Jul 30, 2015, 1:26:41 AM7/30/15
to Elm Discuss, te...@appship.it

I started working on the Sublime plugin first because of lack of feedback. I think it's an afternoon project including a Bash script to make it easy to accept and update contributions by other maintainers. I should have time this weekend though.

very cool! I'll be looking forward to it. Let me know if you need help with anything. 
Reply all
Reply to author
Forward
0 new messages