Implement a simple version of the t helper for the interactive shell #609

Merged
merged 1 commit into from Nov 1, 2012

Projects

None yet

3 participants

@yrashk
Contributor
yrashk commented Oct 31, 2012

Prints out type/spec information

(If Haskell has :t, why can't we have it, too?)

@yrashk
Contributor
yrashk commented Oct 31, 2012
iex(15)> t Enum.t/0 
@type(t() :: Enum.Iterator.t())
:ok
iex(16)> t Enum.all?/2
@spec(all?(t(), fun(element()) do
  boolean()
end)) do
  boolean()
end
:ok
@devinus
Contributor
devinus commented Oct 31, 2012

This is really nice.

@yrashk
Contributor
yrashk commented Oct 31, 2012

@josevalim wdyt?

@yrashk yrashk Implement a simple version of the t helper for the interactive shell …
…(prints out type/spec information)

Also implements corresponding helper functions in Kernel.Typespec
c003817
@josevalim
Member

I love this! Who is working on Googlex? ;) http://www.haskell.org/hoogle/

I believe the code is good, there is just one concern. Today, all in Kernel.Typespec is related to typespecs when a module is being defined. Those new function play directly with the abstract beam code and I wouldn't put them together. Some options are:

  1. Provide __info__(:spec), __info__(:type) and others that would retrieve those from the beam transparently

  2. Create a module specifically for working with beam files and retrieving information from it

PS: @yrashk you don't need to do these changes yourselves, I would just like to figure it out so I can merge and move it to the proper place.

@yrashk
Contributor
yrashk commented Nov 1, 2012

I tend to favour 2) but this is just a small set of helpers over beam_lib, highly related to typespecs only. I believe it might very well belong to Kernel.Typespec as this is related to Kernel.Typespec.to_binary/1

Can we merge this ASAP? Ever since I wrote it I keep missing while debugging typespec related issues in other branches

@yrashk
Contributor
yrashk commented Nov 1, 2012

(and... may be we can merge first, relocate functions [if necessary at all] later?)

@yrashk
Contributor
yrashk commented Nov 1, 2012

We can re-introduce Typespec module if you want?

@josevalim josevalim merged commit 3fac73e into elixir-lang:master Nov 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment