exercism / exercism/elixir-representer

Normalize struct names

Open
#37 12 comments 1 reaction 0 assignees View on GitHub
x:action/improve x:knowledge/elementary x:module/representer x:size/large x:type/coding
Dominant language
Elixir
Stars
11
Forks
8
Avg merge
11d 3h
Merged PRs (30d)
1

Description

This is mentioned in #29.

Struct names should be replaced by placeholders as well.

## Example input

```elixir
defmodule Something do
defstruct [:a, :b]
def something(%Something{a: a}), do: %Something{a: 2 * a}
def something_else(%__MODULE__{a: a}), do: %__MODULE__{a: 3 * a}
end
```

## Desired output

```elixir
defmodule(PLACEHOLDER_1) do
defstruct([:a, :b])
def(PLACEHOLDER_2(%PLACEHOLDER_1{a: PLACEHOLDER_3})) do
%PLACEHOLDER_1{a: 2 * PLACEHOLDER_3}
end
def(PLACEHOLDER_4(%__MODULE__{a: PLACEHOLDER_3})) do
%__MODULE__{a: 3 * PLACEHOLDER_3}
end
end
```

I think `__MODULE__` should not be replaced, because it means different things in different modules. It's already normalized, in a way...

## Current output

```elixir
defmodule(PLACEHOLDER_1) do
defstruct([:a, :b])
def(PLACEHOLDER_2(%Something{a: PLACEHOLDER_3})) do
%Something{a: 2 * PLACEHOLDER_3}
end
def(PLACEHOLDER_4(%__MODULE__{a: PLACEHOLDER_3})) do
%__MODULE__{a: 3 * PLACEHOLDER_3}
end
end
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.