by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 09 04:42
    evhub closed #542
  • Jul 09 04:42
    evhub unlabeled #542
  • Jul 09 04:42
    evhub labeled #542
  • Jun 21 19:29
    evhub closed #546
  • Jun 21 19:29
    evhub commented #546
  • Jun 21 19:29
    evhub labeled #546
  • Jun 21 19:29
    evhub labeled #546
  • Jun 21 12:27
    darleybarreto opened #546
  • Jun 21 01:08
    evhub closed #545
  • Jun 21 01:08
    evhub labeled #545
  • Jun 20 01:29
    evhub labeled #545
  • Jun 20 01:29
    evhub milestoned #545
  • Jun 20 01:29
    evhub labeled #545
  • Jun 20 01:29
    evhub opened #545
  • Jun 19 22:52
    evhub milestoned #544
  • Jun 19 22:52
    evhub labeled #544
  • Jun 19 22:52
    evhub opened #544
  • Jun 18 23:58
    evhub labeled #543
  • Jun 18 23:57
    evhub labeled #542
  • Jun 18 23:57
    evhub labeled #542
dryprogrammer
@dryprogrammer

Hi, I've really enjoyed map$(f ..> print) |> list in Jupyter. However, my codebase is getting large, and it's time to switch to an IDE, but I can't find any that would let me debug and step through the code. ES6 is transpiled but I've been able to debug before. I could only find evhub/coconut#537.

Would you share what is the best way to write larger applications with coconut please?

I've tried:

dryprogrammer
@dryprogrammer
I'm on Mac so I'm now doing VS Code + fswatch -0 file.coco | xargs -0 -n1 coconut-run -l -k --verbose file.coco | pygmentize
Fabien Bourgeois
@Yakulu
Indeed at the moment and AFAIK you can only got syntax highlight on code ditor and than transpile with coconut --strict (to have some style warnings / errors). You can use coconut watch to automatically compile on save. You can use keeplines / line-numbers from CLI too.
debug is not ideal indeed.
dryprogrammer
@dryprogrammer
ok thanks. Thanks for teaching me about --watch. So far, I prefer my Jupyter aesthetics over my terminal. Hopefully, one day there will be a VS Code language extension to enable debugging
Screen Shot 2020-05-22 at 3.03.31 AM.png
dryprogrammer
@dryprogrammer
Screen Shot 2020-05-22 at 3.04.12 AM.png
Evan Hubinger
@evhub
Currently the best way to debug Coconut is just to compile with --line-numbers or --keep-lines, use whatever Python debugging tools you want, and then use the line numbers to figure out where in the Coconut source the error came from.
dryprogrammer
@dryprogrammer

Evan, thanks for reminding me to try the Python debugging tools. It definitely helps. My work flow now is:

  1. Start with Jupyter Coconut IPython kernel to take advantage of the speed of in-memory objects.
  2. Move to Visual Studio Code Python debugger which has Pygmentize for .coco and --line-numbers to help step through the code.

The functional approach is hardly pythonic but the piping and composition makes the code shorter, more readable, and easier to debug, especially when I use multi-line statements using ().

As a former Elm, Jade and CoffeeScript user, I hope more people will adopt Coconut, and hopefully it can influence the introduction of more functional programming, much like how ECMAScript 6 was developed.

Fabien Bourgeois
@Yakulu
@dryprogrammer I agree but I fear that's very difficult to convince people who live in a very object oriented ecosystem to move to a superset and to leave some widely used advanced tools like LSP now
Guido is not very fond of FP style and I guess it won't be widely pushed for Python developers soon
Even if JS is partly functional oriented, redcent ECMA and TS are in the trend of more classical object...
dryprogrammer
@dryprogrammer

haha thanks Fabien. I'm finding Python history more and more interesting each day!
http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html

Facebook's CS PhDs really helped push FP concepts to JS OOP devs through React for wider adoption. Curious to see how Python will evolve.

Fabien Bourgeois
@Yakulu
@dryprogrammer For JS there are people pushing the concept far, like Fantasy-land and all compatible libraries (Crocks, Sanctuary, Fluture etc ). Here @evhub is working on Prelude port to Coconut
Roman Inflianskas
@rominf
I want to use coconut in my project.
coconut uses cPyparsing, which uses Cython.
Some of the users of my project don't have root on their machine.
Is it possible to install coconut without having C/C++ compiler?
Roman Inflianskas
@rominf

I've tried to install it using:

COCONUT_PURE_PYTHON=TRUE pip install --user --upgrade coconut

but cPyparsing is installed anyway.

dryprogrammer
@dryprogrammer
@Yakulu 🙈 Refuge from unsafe JavaScript . That's great! Thank you.
I will try them out on my front-end to see if I'm more productive with Fluture.
I logged in to open an issue to see if anyone else had any catastrophic losses with coconut *.coco. don't try it if you haven't git commit!
Fabien Bourgeois
@Yakulu
@dryprogrammer Sanctuary+Fluture is great IMHO. But there is learning curve ;)
Oh ? You should open an issue on github if you have encountered something reproducible
dryprogrammer
@dryprogrammer
Seeing how much time we spend coding and debugging, that learning curve might be worth it. :)
sure i'll add it to github. oh it's not a bug, more like a feature
Roman Inflianskas
@rominf
Ok, I understood, that I can transpile coconut code to Python and ship it without a need for installing coconut.
dryprogrammer
@dryprogrammer
if I have file1.coco and file2.coco in the folder, coconut *.coco will:
Compiling        file1.coco ...
Compiled to    file2.coco .
Fabien Bourgeois
@Yakulu
@rominf Indeed, you don't have to distribute coconut for final package
dryprogrammer
@dryprogrammer

I logged in to open an issue to see if anyone else had any catastrophic losses with coconut *.coco. don't try it if you haven't git commit!

evhub/coconut#541

22 replies
Roman Inflianskas
@rominf
@Yakulu thanks!
Roman Inflianskas
@rominf
I'm implementing gremlin query language for embedded graph database. Are there any examples on term rewriting written in coconut?
Fabien Bourgeois
@Yakulu
Not sure but as coconut is python 3 superpset, you can progressively implement some coconut from your python files
Which embedded graph database ?
Roman Inflianskas
@rominf
I'm using https://gitlab.com/oddjobz/pynndb2 which is based on LMDB (actually, I'm co-author). The graph database library is not ready yet, so it's in a private GitHub repo.
3 replies
Evan Hubinger
@evhub
@rominf Strange that COCONUT_PURE_PYTHON isn't working for you—can you raise an issue for that? As a temporary workaround, however, pip install --no-deps coconut pyparsing should do what you want.
Evan Hubinger
@evhub
You know what, I think I know what the problem is and I'm not sure if it can be fixed—I'll just change the docs to say to do pip install --no-deps --user --upgrade coconut pyparsing instead of trying to mess with COCONUT_PURE_PYTHON.
Thurston Sexton
@tbsexton
@evhub fyi, put in for coconut support on jupytext mwouts/jupytext#532
Evan Hubinger
@evhub
@tbsexton Looks great! The docs should probably mention jupytext support once it goes live. I've never actually used jupytext before, so I'll have to play around with it.
Roman Inflianskas
@rominf
@evhub Thanks for the suggestion, but it looks like it works only after normal unsuccessful installation, because if I enter this command in a new environment, I get an error:
$ pip install --no-deps --user --upgrade coconut pyparsing
Collecting coconut
  Using cached https://files.pythonhosted.org/packages/c9/53/bfbcdcb7c161e2da2ad142a29c79ff0a198062f616596f220c8c2479a764/coconut-1.4.3-py2.py3-none-any.whl
Collecting pyparsing
  Using cached https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl
Installing collected packages: coconut, pyparsing
Successfully installed coconut-1.4.3 pyparsing-2.4.7
WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ coconut
Traceback (most recent call last):
  File "/home/rominf/.local/bin/coconut", line 6, in <module>
    from coconut.main import main
ModuleNotFoundError: No module named 'coconut'
Evan Hubinger
@evhub
@rominf Hmmm... can you raise an issue for that?
Roman Inflianskas
@rominf
@evhub It was my mistake: I'm using pyenv, so I had to skip --user.
Thurston Sexton
@tbsexton

@evhub I'm just discovering https://plydata.readthedocs.io/en/stable/ and https://plotnine.readthedocs.io/en/latest/index.html .... honestly I use coconut pipes for a lot of what I'm seeing here w.r.t. pandas manipulation.

Any thoughts on using plydata to add native dataframe manipulation into coconut? Much like how fmap works on numpy arrays, etc?

Thurston Sexton
@tbsexton
obviously I can just add the dependency, I suppose. It just seems like some decent additions to the list of builtins
Evan Hubinger
@evhub
@tbsexton fmap support is pretty simple if there's an equivalent of map or np.vectorize—if you know of how you would do that in either framework definitely raise an issue and include it and it should be pretty straightforward to implement from there.
You can also just add an __fmap__ to the base class.
Elliott Indiran
@eindiran
This is an interesting PEP: https://www.python.org/dev/peps/pep-0622/
Evan Hubinger
@evhub
That's pretty exciting!
hsolatges
@hsolatges
Hi there. Enjoying Coconut magic! Thanks. Still I am wondering: what would be the nicest way (Coconut's way) to insert an element in a List? Given that list.insertreturns None. I would like to insert a midle point inbetween two points:[(0,1),(1,0)] -> [(0,1), (.5,.5),(1,0)]. I achieved it with a temp copy but I wondér if there is a pipe way, or a better way... Thanks!
Evan Hubinger
@evhub

@hsolatges You could try something like

def insert(iterable, loc, item) = iterable$[:loc] :: (item,) :: iterable$[loc:]

which is nice because it's more functional and works on any iterable.

If you need it to work on iterators rather than just iterables, though, you might want to do

def insert_iterator(iterator, loc, item) = reit$[:loc] :: (item,) :: reit$[loc:] where: reit = reiterable(iterator)

and if you need the result to be a list you can just call list at the end.

hsolatges
@hsolatges
@evhub Awesome! Thank you! :)
hsolatges
@hsolatges
It is nice to have that reiterable function