[erlang-questions] json to map

Roelof Wobben r.wobben@REDACTED
Fri Aug 28 14:34:36 CEST 2015


Op 28-8-2015 om 13:50 schreef Kevin Montuori:
>>>>>> "rw" == Roelof Wobben <r.wobben@REDACTED> writes:
>      rw> -type tword()  :: binary().
>      rw> -type token() :: tInt()
>      rw>              | tWord()
>
>      rw> time_parser.erl:12: type tInt() undefined time_parser.erl:13: type
>      rw> tWord() undefined
>      rw> time_parser.erl:6: Warning: type tword() is unused
>
> [Leaving aside all of the excellent advice that's been proffered...]
>
> Did you read these messages carefully?  tWord() is undefined but tword()
> is unused: the answer's staring you in the face.  If you've been writing
> Erlang for a while this error/warning pair should ring a bell.
>
> Perhaps you should revisit Mr. O'Keefe's email, specifically the part
> where he discusses Erlang naming conventions (and tells you *exactly*
> what's wrong with what you have)?
>
>
> k.
>

With the help of everything I found this piece working.

-module(time_parser).

-export([]).

-type token() :: t_Int()
              | t_Word()
              | '/'
              | '-'
              | ','.

-type t_Int()   :: integer() | int.
-type t_Word()  :: word | string().

So in normal Englisch a token can be a t-int , a t_word , a / , a - or a 
, If its something else its failing which is allright.
type t_int can be a integer or a atom called int.
type t_word can be a string or a atom called word.
if it' something else it's failing.

Roelof




More information about the erlang-questions mailing list