10

I am both an Elm and a functional programming newbie, and never worked with Java seriously. I'm working my way through Elm docs, and playing with the REPL, trying to understand type annotations.

They seem pretty useful things:

type alias Point = { x:Float, y:Float }

origin : Point
origin =
  { x = 0, y = 0 }

and now all your Points are specifically formatted floats! Magic. Love it. Would love to play around with it in the REPL, but the REPL doesn't seem to understand type definitions:

> type alias Point = { x:Float, y:Float }
> origin : Point
-- SYNTAX PROBLEM -------------------------------------------- repl-temp-000.elm

I ran into something unexpected when parsing your code!

7│   origin : Point
            ^
I am looking for one of the following things:

    end of input
    whitespace

Is this a bug in the REPL, or a feature?

Dmitri
  • 2,658
  • 2
  • 25
  • 41

1 Answers1

11

The elm repl does not currently support type annotations. There's a lot of people asking for this so I'm holding out hope for it soon.

Chad Gilbert
  • 36,115
  • 4
  • 89
  • 97
  • Thanks. That really is too bad. Eml-reactor is pretty groovy, but I can't run it in my Emacs, and can't examine functions by just typing their name. But I'd give two upvotes for your answer for helping me find https://github.com/elm-community – Dmitri Dec 19 '15 at 22:59
  • 1
    Check out [elm-mode for emacs](https://github.com/jcollard/elm-mode). The elm-oracle integration gives you some of that in-editor inspection capability – Chad Gilbert Dec 19 '15 at 23:20