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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Letters in signatures always get incremented. Results in running out of letters quickly. #14

Closed
pya opened this issue Aug 2, 2015 · 2 comments
Labels

Comments

@pya
Copy link
Contributor

pya commented Aug 2, 2015

This test script:

from __future__ import print_function

from hask import H, sig, _t

for x in range(10):
    @sig(H / 'a' >> 'b')
    def f1(a):
       return a

    @sig(H / 'a' >> 'b')
    def f2(a):
       return a

    print('f1:', _t(f1))
    print('f2:', _t(f2))

Produces this output (Note: _t has been modified to return instead of printing.) :

f1: (a -> b)
f2: (c -> d)
f1: (e -> f)
f2: (g -> h)
f1: (i -> j)
f2: (k -> l)
f1: (m -> n)
f2: (o -> p)
f1: (q -> r)
f2: (s -> t)
f1: (u -> v)
f2: (w -> x)
f1: (y -> z)
f2: ({ -> |)
f1: (} -> ~)
f2: ( -> ?)
f1: (? -> ?)
f2: (? -> ?)
f1: (? -> ?)
f2: (? -> ?)

Wouldn't it be better start afresh with a for each function? There are two cases were this really matters:

  1. Defining many functions.
  2. Working interactively, for example in an IPython Notebook, and redefining a function again and again.

Both scenarios can lead to a running out of printable characters.

@billpmurphy billpmurphy added the bug label Aug 2, 2015
@billpmurphy
Copy link
Owner

I agree; it might also help to use numbers (e.g. a1), which ghci also does.

@billpmurphy
Copy link
Owner

I should add--letters are not actually "used" until the type signature is printed. The type variables themselves have unique (integer) identifiers within the type system; these are mapped to letters lazily, at time of printing.

As a quick fix, _t could be modified so that it resets the pool of letters when it is called. However, I think a larger revamp of the type printing system makes more sense, because of the problem highlighted in #15.

billpmurphy added a commit that referenced this issue Aug 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants