Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Short exercises to learn how generic types and type variables work in Elm.

Generic Elm types exercises

A series of exercises to get a feel for how generic types and type variables work in Elm. For each of these, you are given some code that is not compiling. Your task is to get it compiling. You can change the body of the function but not the signature. No cheating with Debug.todo or infinite recursions either 😉

Hint: the more generic your signature, the less you can do in the function body.

@eimfach
Copy link

eimfach commented Sep 15, 2019

Is it okay to change the body to [] or Nothing in case of the first List and Maybe ? :P That was the first thing I came up with

Loading

@JoelQ
Copy link
Author

JoelQ commented Sep 16, 2019

@eimfach yes! Those are the sorts of answers these exercises are looking for. In many cases, those are the only implementations that will compile (other than Debug.todo, infinite recursions, and similar implementations that work no matter what the signature is).

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment