Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion prettypr and spec
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Roberto Ostinelli  
View profile  
 More options Sep 25 2012, 12:00 am
From: Roberto Ostinelli <robe...@widetag.com>
Date: Mon, 24 Sep 2012 21:00:00 -0700
Subject: [erlang-questions] prettypr and spec

I have this code:

%%%%%%%%%%%%%%%%%%%%%%%%
-module(mymodule).
-export([hello/0, goodbye/0, greetings/1]).

-spec hello() -> string().
hello() ->
greetings("hello").

-spec goodbye() -> string().
goodbye() ->
greetings("goodbye").

-spec greetings(Text::string()) -> string().
greetings(Text) ->
lists:flatten(io_lib:format("~s sublimerl", [Text])).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").

simple_test() ->
?assertEqual("hey sublimerl", greetings("hey")).

greetings_test_() ->
[?_assertEqual("hey sublimerl", greetings("hey"))].

-endif.
%%%%%%%%%%%%%%%%%%%%%%%%

when i convert it using this:

%%%%%%%%%%%%%%%%%%%%%%%%
Formatted = case epp_dodger:parse_file(FilePath) of
{ok, Forms} ->
case lists:keymember(error, 1, Forms) of
false ->
erl_prettypr:format(erl_recomment:recomment_forms(Forms,
erl_comment_scan:file(FilePath)));
true ->
""
end;
{error, _} ->
""
end
%%%%%%%%%%%%%%%%%%%%%%%%

I get:

%%%%%%%%%%%%%%%%%%%%%%%%
-module(mymodule).

-export([hello/0, goodbye/0, greetings/1]).

-spec({{hello, 0},
       [{type, 4, 'fun',
 [{type, 4, product, []}, {type, 4, string, []}]}]}).

hello() -> greetings("hello").

-spec({{goodbye, 0},
       [{type, 8, 'fun',
 [{type, 8, product, []}, {type, 8, string, []}]}]}).

goodbye() -> greetings("goodbye").

-spec({{greetings, 1},
       [{type, 12, 'fun',
 [{type, 12, product,
   [{ann_type, 12,
     [{var, 12, 'Text'}, {type, 12, string, []}]}]},
  {type, 12, string, []}]}]}).

greetings(Text) ->
    lists:flatten(io_lib:format("~s sublimerl", [Text])).

-ifdef(TEST).

-include_lib("eunit/include/eunit.hrl").

simple_test() ->
    ?assertEqual("hey sublimerl", (greetings("hey"))).

greetings_test_() ->
    [?_assertEqual("hey sublimerl", (greetings("hey")))].

-endif.
%%%%%%%%%%%%%%%%%%%%%%%%

What happens to spec? What is the best way to use an erlang auto-formatter?

Any input welcome.

r.

_______________________________________________
erlang-questions mailing list
erlang-questi...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.