I suggest we ...

What do you think to add F# atom data type as it's used in Erlang?

I think to implement Erlang like atoms can add language more readability more precise pattern matching. More here http://www.erlang.org/doc/reference_manual/data_types.html#id66445.

4 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Martin Bodocky shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

4 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Martin Bodocky commented  ·   ·  Flag as inappropriate

    Daniel, your approach is right! I really cannot argue, you convinced me I don't need atoms in pattern matching also I see advantage when I upgrade RequestType compiler will push me to update my code. You see that's why I love F# I learn new thing every day.

  • Daniel Fabian commented  ·   ·  Flag as inappropriate

    I meant, in what is it diffent from a DU like:

    type RequestType = Remove | Add

    let receive request =
    match request with
    | Remove, value -> action()
    | Add, value -> anotherAction()

    in this case the DU RequestType is reeally either Remove or Add but both cases have no value associated with them. The "Remove" or "Add" are the values themselves.

  • Martin Bodocky commented  ·   ·  Flag as inappropriate

    Atom is represent as value it self, for example atom is 'request' is just request is not string is atom. It should be differentiate from other variables, in Erlang should start by lower case or '.

    Let's imagine we have atom in F# and we decide atoms in F# should start with one single quote like 'atom.

    The reall example can be in pattern matching like :

    let receive request =
    match request with
    | 'remove, Value -> action()
    | 'add, Value -> action()

    The atom 'remove is static, the variable request is tuple if atom and another data value type.
    DU defines data by data value types, atoms are valueless in this sense.

    I hope this helps you, if no I will try explain again, I don't know your level of Erlang :)

F# Language

Feedback and Knowledge Base