Giter Club home page Giter Club logo

hydiomatic's People

Contributors

algernon avatar brandonwillard avatar tuturto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hydiomatic's Issues

TypeError when trying to use program

I was curious what Hydiomatic would say about my little timer (thanks for the Star, by the way), but it throws a TypeError and dies:

(hydiomatic)zmd@ExpectedReturn:~/Code/Examination/hydiomatic$ bin/hydiomatic.hy ~/Code/HyTimer/timer.hy 
Traceback (most recent call last):
  File "/home/zmd/Code/Examination/hydiomatic/bin/hy", line 9, in <module>
    load_entry_point('hy==0.9.12', 'console_scripts', 'hy')()
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/cmdline.py", line 295, in hy_main
    sys.exit(cmdline_handler("hy", sys.argv))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/cmdline.py", line 283, in cmdline_handler
    return run_file(options.args[0])
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/cmdline.py", line 190, in run_file
    import_file_to_module("__main__", filename)
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/importer.py", line 74, in import_file_to_module
    eval(ast_compile(_ast, fpath, "exec"), mod.__dict__)
  File "bin/hydiomatic.hy", line 349, in <module>

  File "bin/hydiomatic.hy", line 24, in process_file
    (apply printer [(transform (import-file-to-hst fn) rules)]
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 38, in simplify
    (setv new-expr (prewalk (fn [x] (simplify-step x rules)) expr))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 39, in walk
    ((type form) (outer (HyExpression (map inner form))))]
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 32, in walk
    (outer (HyExpression (map inner form)))]
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 39, in walk
    ((type form) (outer (HyExpression (map inner form))))]
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 39, in walk
    ((type form) (outer (HyExpression (map inner form))))]
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 32, in walk
    (outer (HyExpression (map inner form)))]
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 32, in walk
    (outer (HyExpression (map inner form)))]
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/contrib/walk.hy", line 50, in prewalk
    (walk (partial prewalk f) identity (f form)))
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 38, in _hy_anon_fn_6
    (setv new-expr (prewalk (fn [x] (simplify-step x rules)) expr))
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 33, in simplify_step
    (setv new-expr (simplify-step-by-rule rule new-expr)))
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 23, in simplify_step_by_rule
    (let [[alts (run* [q] (rule expr q))]]
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 23, in _hy_anon_fn_3
    (let [[alts (run* [q] (rule expr q))]]
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 23, in _hy_anon_fn_2
    (let [[alts (run* [q] (rule expr q))]]
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/core.hy", line 23, in :res_1280
    (let [[alts (run* [q] (rule expr q))]]
  File "/home/zmd/Code/Examination/hydiomatic/src/adderall/adderall/dsl.hy", line 124, in _hy_anon_fn_31
    (for [opt-s1 (g1 s)]
  File "/home/zmd/Code/Examination/hydiomatic/src/adderall/adderall/dsl.hy", line 126, in _hy_anon_fn_31
    (yield-from (g2 opt-s1)))))) goals)
  File "/home/zmd/Code/Examination/hydiomatic/src/adderall/adderall/dsl.hy", line 126, in _hy_anon_fn_31
    (yield-from (g2 opt-s1)))))) goals)
  File "/home/zmd/Code/Examination/hydiomatic/src/adderall/adderall/dsl.hy", line 126, in _hy_anon_fn_31
    (yield-from (g2 opt-s1)))))) goals)
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/rulesets/syntaxo.hy", line 65, in _hy_anon_fn_16
    (project [?params ?m ?o]
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/rulesets/syntaxo.hy", line 65, in _hy_anon_fn_15
    (project [?params ?m ?o]
  File "/home/zmd/Code/Examination/hydiomatic/hydiomatic/rulesets/syntaxo.hy", line 67, in _hy_anon_fn_14
    (≡ ?call-name (+ ?o ?m)))))
  File "/home/zmd/Code/Examination/hydiomatic/src/hy/hy/models/list.py", line 37, in __add__
    return self.__class__(super(HyList, self).__add__(other))
TypeError: can only concatenate list (not "HySymbol") to list

I made a wild guess that maybe it might be a Python 2 vs. 3 issue (because the file to be analyzed runs under the Hy I got from "sudo pip3 install hy" whereas I was running Hydiomatic from a Python 2 virtualenv) but I get the same thing in a Python 3 venv. The installation of Hydiomatic itself seems okay, because it can at least turn (= (% x 2) 0) into (is_even x) in a test file I made.

Options for source and target Hy versions

As mentioned here, we should probably add source and target versions to the rulesets and command line. This would allow us to safely reinstate the old and new Hy syntax transformations rules that currently clash.

Obfuscation support

While it's nice that we can simplify Hy code, but it would be useful if we could obfuscate it as well. Sadly, simply running the rules backwards will not work, they'll never terminate (or they'll even die, if they assume we always have the expression available).

So, we need a way to obfuscate code, preferably one that allows us to reuse the existing rules, or at least some of them.

Add missing/new `import`s and `require`s

Per this discussion, for some of the new Hy update rules, we will need to add new import and require statements.

The additions will need to be scoped somewhat intelligently (e.g. the outer-most scope that encompasses more than one use of the import/require). For standard Python-scoped objects, this isn't too complicated, but for macros—especially pre hylang/hy#1682—the naive per-line/in-place addition might be necessary.

Link to aderall in README

currently aderall mentioned in project's readme does not point to right location. Just something to keep in mind when updating the readme, next time

The rules/optimo optimisation is wrong

The optimisation ends up doing this:

(setv (, a b c) [1 2 3])

Now if any of the values tries to reference a former var, this will fail. We really need separate setvs.

A couple of rule ideas

  • (= (% n 2) 0)) => (even? n)
  • (= (% n 2) 1)) => (odd? n)
  • (isinstance x type) => (instance? type x)
  • (isinstance x float) => (float? x)
  • (isinstance x int) => (integer? x)
  • (none? x) => (nil? x)
  • (isinstance x string), (isinstance x unicode) => (string? x)
  • (for* [x iterable] (yield x)) => (yield-from iterable)

miniKanren-based iterations/fixed points

Can the [pre/post]walk and fixed-point iterations be performed in miniKanren (e.g. using recursive relations, conde/alwayso/anyo, etc.)?

If so, are there any advantages to doing that?

Post-macro hydiomaticy with `(let)`

When given something like:

(defn foo [x]
  (let [[y (inc x)]]
    (print x y)))

Hy will create something like:

(defn foo [x]
  ((fn [] (setv y (inc x))
    (print x y))))

It'd be nice if we could get rid of the inner function

Wrong suggestion when multiple suggestions race

(defmacro if-true [condition &rest stuff] 
  `(if (not (is False ~condition)) ~@stuff))

This gets simplified to (unless (is False ~condition) ~@stuff), which is wrong in multiple ways:

  1. The ~@stuff can expand to both branches, so unless is wrong here.
  2. Instead of simplifying (if (not ...)) to (if-not ...), it should favour (not (is False)) => (is-not False).

Support injecting code from within rules

The warning rules print their warning, so they appear out of order when running hydiomatic.hy. The warnings also do not appear at all when running without diff mode.

To fix this, hydiomatic should be taught to recognise injected code, when the returned form has multiple members. It's not easy to do that, because we need to distinguish between arrays and injected code...

-> rules are slightly broken

(-> a (b)) should simplify to (b a), but it doesn't, simplifies to ((b) a), which is wrong. Also, (-> a (foo b)) simplifies badly too, the rules of threading are not followed at all. Will need to revisit.

HySyntaxError on import using Hy v0.16 on latest Pypi release

When using the latest hydiomatic release with Hy v0.16.0, I got the following error:

hydiomatic.hy -h
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 261, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "<frozen importlib._bootstrap_external>", line 860, in get_code
  File "/home/yoan/.local/bin/hydiomatic.hy", line 3
    [argparse]
    ^
hy.errors.HySyntaxError: parse error for special form 'import': should have reached end of form: HyList([
  HySymbol('argparse')])

Following the Hy CHANGELOG, release 15, that states:

(import [foo]) is no longer allowed. Use (import foo) instead.

Which seems to have been fixed in f7e56e2

Could it be possible to make a new Pypi release including the fixes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.