Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/expo/message.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ defmodule Expo.Message do
"""
@type t :: Singular.t() | Plural.t()

@typedoc """
The key that can be used to identify a message.

See `key/1`.
"""
@opaque key :: Singular.key() | Plural.key()
@typep key ::
{msgctxt :: String.t(), msgid :: String.t()}
| {msgctxt :: String.t(), msgid :: String.t()}

@doc """
Returns a "key" that can be used to identify a message.
Expand Down
11 changes: 2 additions & 9 deletions lib/expo/message/plural.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ defmodule Expo.Message.Plural do
"""
@type block :: :msgid | {:msgstr, non_neg_integer()} | :msgctxt | :msgid_plural

@typedoc """
Metadata for this struct.
"""
@opaque meta :: %{optional(:source_line) => %{block() => non_neg_integer()}}

@typedoc """
The key that identifies this message.
"""
@opaque key :: {msgctxt :: String.t(), msgid :: String.t()}
@typep meta :: %{optional(:source_line) => %{block() => non_neg_integer()}}
@typep key :: {msgctxt :: String.t(), msgid :: String.t()}
Comment on lines +22 to +23
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were effectively public API. Are we sure w should get rid of them?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that applies to all of them. We have 3 choices:

  • Fully Public - I don't want to guarantee anything for them around not changing them whenever we see fit.
  • Opaque - Produces Errors
  • Private - Enough to deal with it internally

So I decided for typep.

But I don't like any of the options we're given at the moment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah me neither, the fact that these produce errors is pretty frustrating


@typedoc """
The type for this struct.
Expand Down
11 changes: 2 additions & 9 deletions lib/expo/message/singular.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@ defmodule Expo.Message.Singular do
"""
@type block :: :msgid | :msgstr | :msgctxt

@typedoc """
Metadata for this struct.
"""
@opaque meta :: %{optional(:source_line) => %{block() => non_neg_integer()}}

@typedoc """
The key that identifies this message.
"""
@opaque key :: {msgctxt :: String.t(), msgid :: String.t()}
@typep meta :: %{optional(:source_line) => %{block() => non_neg_integer()}}
@typep key :: {msgctxt :: String.t(), msgid :: String.t()}

@typedoc """
The type for this struct.
Expand Down
18 changes: 6 additions & 12 deletions lib/expo/plural_forms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,12 @@ defmodule Expo.PluralForms do
plural: plural_ast()
}

@typedoc """
The AST of a plural forms expression.
This is evaluated internally to determine the plural form for a given number
using `index/2`, and is not meant to be inspected directly.
"""
@opaque plural_ast() ::
:n
| integer()
| {:!= | :> | :< | :== | :% | :<= | :>= | :&& | :||, plural_ast(), plural_ast()}
| {:if, plural_ast(), plural_ast(), plural_ast()}
| {:paren, plural_ast()}
@typep plural_ast() ::
:n
| integer()
| {:!= | :> | :< | :== | :% | :<= | :>= | :&& | :||, plural_ast(), plural_ast()}
| {:if, plural_ast(), plural_ast(), plural_ast()}
| {:paren, plural_ast()}

@doc """
Parses a plural forms string into a `t:t/0` struct.
Expand Down