learnyouanelm / learnyouanelm.github.io

“Learn You an Elm!”, based on LYAH by Miran Lipovača
http://learnyouanelm.github.io/
93 stars 16 forks source link

Need a nice way to inspect types #8

Open deadfoxygrandpa opened 8 years ago

deadfoxygrandpa commented 8 years ago

I'm not sure the best way to inspect types. elm-repl can do it, but it seems like one of the strengths of beginner Elm is that you don't need to install anything on your computer to get started.

We could maybe do something like type holes? If we extend the toPrint example from the previous chapter, we could turn it into a template like this:

import Graphics.Element exposing (show)

type Type = Type

toPrint : Type toPrint = 'a'

main = show toPrint And then when you hit Compile you'd get an error message like

The type annotation for toPrint does not match its definition.

12| toPrint : Type The type annotation is saying:

Type

But I am inferring that the definition has this type:

Char

Which we could try to explain? I'm not sure what the best way to proceed is. Can you think of something else?