elm-repl icon indicating copy to clipboard operation
elm-repl copied to clipboard

Function signature

Open flip111 opened this issue 9 years ago • 10 comments

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.

flip111 avatar Oct 31 '15 00:10 flip111

(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.

igrep avatar Nov 02 '15 10:11 igrep

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

flip111 avatar Nov 02 '15 14:11 flip111

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

sjfloat avatar Mar 17 '16 20:03 sjfloat

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

wjdhamilton avatar Apr 01 '16 15:04 wjdhamilton

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

RyanCCollins avatar Nov 13 '16 03:11 RyanCCollins

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.

FernandoBasso avatar Jul 25 '17 09:07 FernandoBasso

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).

craigmaloney avatar Aug 25 '17 14:08 craigmaloney

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.

hsribei avatar Oct 06 '17 18:10 hsribei

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.

shamansir avatar Nov 17 '17 10:11 shamansir

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.

zulrang avatar Mar 16 '18 04:03 zulrang