elm-lang / elm-repl

A REPL for Elm
BSD 3-Clause "New" or "Revised" License
170 stars 34 forks source link

Function signature #86

Open flip111 opened 9 years ago

flip111 commented 9 years ago

I'm pretty much forwarding this ... but i get asked frequently if the repl supports function signatures. I think it might be useful when starting out with elm and quickly trying stuff with types.

igrep commented 9 years ago

(Sorry if this question should be answered in elm-discuss.)

You mean you want to know the signature from elm-repl?

$ elm-repl
Elm REPL 0.4.2 (Elm Platform 0.15.1)
  See usage examples at <https://github.com/elm-lang/elm-repl>
  Type :help for help, :exit to exit
> identity
<function> : a -> a
> (<|)
<function> : (a -> b) -> a -> b
> (+)
<function> : number -> number -> number

Just typing the name of function works.

flip111 commented 9 years ago

no i mean to define a new function and giving a type signature along with it

sjfloat commented 8 years ago

+1 I keep forgetting I can't do that.

wjdhamilton commented 8 years ago

:+1: This would be helpful since you can't follow the tutorials in the repl without this functionality

RyanCCollins commented 8 years ago

I also ran into this and was a bit thrown off when following the online tutorials. Just thought I would mention it. Many thanks!

FernandoBasso commented 7 years ago

It says here:

In the Core Language section of this book, we ran a bunch of code in the REPL. Well, we are going to do it again, but now with an emphasis on the types that are getting spit out. So type elm repl in your terminal again.

Okay, it doesn't say you can write type annotations in the repl, but it is still a bit misleading. I, for one, thought I would use the repl for the entire code on that page (or would expect different instructions on how to run code from a file, or a link to those instructions).

Edit: Just found this faq entry.

craigmaloney commented 7 years ago

It seems like the error message is almost there (it detects that you're doing a type annotation) but it doesn't tell you why it's an error (You're attempting to do type annotations in the REPL, which are unsupported).

I'm just learning the language as well, and it seems like type annotations should be something that can be played with in the REPL. Even Try Elm has some support for them (but alas, it's not as nice as the REPL for on-the-go toy code).

hsribei commented 7 years ago

Is there a plan to support type annotations in the repl? I got here from #113. I was searching for the error described there after trying to send some code from an emacs buffer to the repl via elm-mode by selecting it and typing C-c C-p. Allowing type annotations would make this interaction between editing files and interactive testing in the repl a lot smoother.

shamansir commented 7 years ago

If you are still searching for type annotations in REPL, now there's an alternative for you: https://github.com/shamansir/ielm supports getting types and values for any kind of expression (except just a few, where it falls back to string representation, which is also not so bad).

screen shot 2017-11-17 at 11 09 13

The complete video with all the current features is here: https://vimeo.com/242822314

P.S. It is usable, but still in early development, so please don't expect anything to work, but as long as there is an issue exists for a found bug, it will very soon be fixed.

zulrang commented 6 years ago

I'm also a noob that ran into this problem. If you follow the guide.elm-lang.org word-for-word, you will run into this because you can't actually follow the instructions.