Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

alternative syntax #12

Closed
stoeffel opened this issue Dec 1, 2016 · 11 comments
Closed

alternative syntax #12

stoeffel opened this issue Dec 1, 2016 · 11 comments

Comments

@stoeffel
Copy link
Owner

stoeffel commented Dec 1, 2016

from discussion in #10

The current implementation is the same as python's doctest.

{-|
    >>> indexOfLineWithEquals
    ...      <| Array.fromList
    ...      <| String.lines "a\nb\nc = d\nf = d\n"
    2
-}

vote 馃憤

{-|
    > indexOfLineWithEquals
    #      <| Array.fromList
    #      <| String.lines "a\nb\nc = d\nf = d\n"
    2
-}

vote 馃槃

{-|
    > indexOfLineWithEquals
    ~      <| Array.fromList
    ~      <| String.lines "a\nb\nc = d\nf = d\n"
    2
-}

vote 馃帀

{-|
    > indexOfLineWithEquals
    \      <| Array.fromList
    \      <| String.lines "a\nb\nc = d\nf = d\n"
    2
-}

vote 鉂わ笍

{-|
    > indexOfLineWithEquals
    |      <| Array.fromList
    |      <| String.lines "a\nb\nc = d\nf = d\n"
    2
-}

vote : 馃槙 (sorry for the emoji, there aren't many options)

@stoeffel stoeffel mentioned this issue Dec 1, 2016
@stoeffel
Copy link
Owner Author

stoeffel commented Dec 1, 2016

I would vote for 馃帀 if we decide on going with an alternative solution. I still think that using one character can be confusing and can be mistaken for part of the code, where ... and >>> is more obvious.

@stoeffel
Copy link
Owner Author

stoeffel commented Dec 2, 2016

btw. haskell doctest also uses >>>

@AnthonyJacob
Copy link

AnthonyJacob commented Dec 11, 2016

Why the hell are you trying to invent new syntax when elm-repl has already established one?

> (\a -> a)
| [ 2
| , 3
| , 5
| ]
[2,3,5] : List number

I vote for non of the above but for the elm-repl one!

Or there is another option. Make elm-repl use the new docs syntax you choose instead of its current one!

@despairblue
Copy link

@AnthonyJacob good idea to consider the elm repl syntax as well, although the tone of your suggestion can be improved.

I'd also vote for the elm repl syntax.

@stoeffel
Copy link
Owner Author

I included repl-style in the poll.
The reason why I don't like the syntax with only one char is, it can easily be confused to be a typo. >>> is more obvious.
The reason why I am against repl-style is, because:

  • it implies that elm-doc-test uses the repl to run your tests
  • you need \ to start a new line in repl and you don't have to type > or |
  • >>> is used in a doctest for other languages (more familiar to newcomers)
  • >>> is easier to search

@AnthonyJacob
Copy link

AnthonyJacob commented Dec 11, 2016

I am sorry for that tone, I was going trough some packages-extra made by haskellers and it wasn't pleasant experience :)

you need \ to start a new line in repl

I hope that in the near feature this won't be the case. ( shift+enter is much more convenient )

in repl you don't have to type > or |

Once there will be good IDE support for documentation, you also won't need it. It might feel exactly like the repl actually.

...

All the other things you pointed out can be solved by one bold line in documentation.

On the other hand, if the change would get propagated into repl, I would go with the first one.

@eeue56
Copy link
Collaborator

eeue56 commented Dec 11, 2016

Why the hell are you trying to invent new syntax when elm-repl has already established one?

This tone is not okay. This is an open source project that we have spent time on. We've also asked for people's feedback in multiple places on the syntax.

I vote for non of the above but for the elm-repl one!

The reason why the prompt does not matter is because 1) >>> is not going seem much different from > to beginners 2) doc tests are not completely equivalent to the repl and 3) clear, defining syntax is important in doctest parsing.

Haskell's doctests do not prefix things with Prelude>. In languages like Python, where doctests came from, there is a lot of confusion for beginners when doctests do not behave like the REPL. An example is how strings are handled. Very confusing. Even more confusing considering that multiple languages have different prompts and syntax handling entirely. I think this is a solution to a problem that nobody will have. However, if you can present somebody who's confused by the use of >>> over >, I'm happy to change my opinion.

I am sorry for that tone, I was going trough some packages-extra made by haskellers and it wasn't pleasant experience :)

If you are having a bad day, talk it out with someone else - don't take it out on people who are giving up their free time to work on projects.

I hope that in the near feature this won't be the case. ( shift+enter is much more convenient )
Once there will be good IDE support for documentation, you also won't need it. It might feel exactly like the repl actually.

Wishful thinking. Maybe if we planned this whole library around Elm having reflection then we wouldn't even need to generate elm-tests! Except that's not how things are right now, and to plan on some non-existent tooling changes at some point in the future is not a good way to get things done.

@AnthonyJacob
Copy link

Maybe if we planned this whole library around Elm having reflection then we wouldn't even need to generate elm-tests!

So it is easier to write generator instead of making a pull request that would bring reflection into elm?

@eeue56
Copy link
Collaborator

eeue56 commented Dec 11, 2016

Adding reflection is a huge design decision, it's not as simple as just adding a pr. So yes.

@AnthonyJacob
Copy link

Is / Was there some discussion on this topic (reflection) ? I wanted to make elm-repl better at exploration of the language / libraries / documentation etc. which would very likely require some amount of reflection ( even if only repl would have permission to use it ).

@stoeffel
Copy link
Owner Author

stoeffel commented Jun 8, 2017

closed in favour of #22

@stoeffel stoeffel closed this as completed Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants