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

MapSet parsing problems #2

Closed
boxxxie opened this issue Oct 26, 2016 · 4 comments
Closed

MapSet parsing problems #2

boxxxie opened this issue Oct 26, 2016 · 4 comments

Comments

@boxxxie
Copy link

boxxxie commented Oct 26, 2016

i write out a mapset to edn, then read it back from edn, and they don't look the same

edn

[#{{<<"Ahmad Abdalla">>,<<"Natasha Taylor">>} {<<"Dave Hurley">>,<<"Ken Ip">>} {<<"Eric  Arnold">>,<<"Paul Iannazzo">>} {<<"Eric Rogness">>,<<"Kim Ghattoura">>} {<<"Harry  McLaughlin">>,<<"Sam Holako">>} {<<"Izzie Colpitts-Campbell">>,<<"Olaf  Arason">>} {<<"Lauren Arnold">>,<<"Michael Rowe">>} {<<"Michael Wickware">>,<<"Naomi Cowan">>} {<<"Quinn  Strahl">>,<<"Robert Peacock">>}} #{{<<"Ahmad Abdalla">> ...

when i read it back in i get

{:ok,
 [#MapSet<[%{{:symbol, :"<<"} => "Dave Hurley",
     {:symbol, :">>"} => {:symbol, :"<<"}, "Ken Ip" => {:symbol, :">>"}},
   %{{:symbol, :"<<"} => "Eric Rogness", {:symbol, :">>"} => {:symbol, :"<<"},
     "Kim Ghattoura" => {:symbol, :">>"}},
   %{{:symbol, :"<<"} => "Lauren Arnold", {:symbol, :">>"} => {:symbol, :"<<"},
     "Michael Rowe" => {:symbol, :">>"}},
   %{{:symbol, :"<<"} => "Michael Wickware" ...

i don't understand why there are << and >> in my file. seems like very erlang like things.
i expect the output to be only edn format,

@psfblair
Copy link
Owner

How are you printing out the output? Note that Elixir has two string formats, one of which is called a binary (see http://elixir-lang.org/getting-started/binaries-strings-and-char-lists.html). If you are using iex to output the edn you'll get the angle-bracket notation because the strings are in binary format.

However, just outputting the edn to a variable and then reading back in from that variable shouldn't give you the problem you see. (I believe there are tests that establish that.) If that's a problem, then there's something wrong.

I believe IO.puts will give you a string output that doesn't contain the angle brackets.

@boxxxie
Copy link
Author

boxxxie commented Oct 31, 2016

could an issue be that I'm using tuples?

@psfblair
Copy link
Owner

psfblair commented Nov 2, 2016

I don't believe there is any conversion from Elixir tuples to edn, since edn doesn't have a tuple type.

However, the angle brackets almost certainly comes from the way Elixir represents a binary string format when inspected. You'll get those if you write to edn in a format that doesn't recognize those as strings, and then when you attempt to read back the serialized edn with the angle brackets you'll get the problem you see.

@boxxxie
Copy link
Author

boxxxie commented Nov 21, 2016

Thanks for your replies. i've stopped using tuples. :)

@boxxxie boxxxie closed this as completed Nov 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants