<!-- livebook:{"persist_outputs":true} -->
# IceCream
## Section
IceCream is a port of the [python package](https://github.com/gruns/icecream) of the same name.
#### Never use `IO.inspect()` again
Use IceCream to inspect any Elixir term with an automatically generated label.

## Installation
The package can be installed by adding `ice_cream` to your list of dependencies in `mix.exs` . It should only be added for the `dev` and `test` environments.
```
def deps do
[
{:ice_cream, "~> 0.0.5", only: [:dev, :test]}
]
end
```
The docs can be found at [https://hexdocs.pm/ice_cream](https://hexdocs.pm/ice_cream).
## Usage
Use IceCream in place of `IO.inspect/2` . So write `ic(value)` instead of
`IO.inspect(some_value, label: "some_value")`
It can also be used inside of pipelines. You can write:
```elixir
Mix.install([{:ice_cream, path: "./"}])
```
```output
:ok
```
```elixir
defmodule SomeModule do
import IceCream
defp fabricate(data), do: data
defp cleanup(data), do: data
def some_fun(data) do
data
|> ic()
|> fabricate()
|> ic()
|> cleanup()
|> ic()
end
end
SomeModule.some_fun("<data>")
```
```output
ic| data: "<data>"
ic| fabricate(data): "<data>"
ic| cleanup(fabricate(data)): "<data>"
```
```output
"<data>"
```
Instead of:
```elixir
defmodule SomeModule do
defp fabricate(data), do: data
defp cleanup(data), do: data
def some_fun(data) do
data
|> IO.inspect(label: "data")
|> fabricate()
|> IO.inspect(label: "fabricate")
|> cleanup()
|> IO.inspect(label: "cleanup")
end
end
SomeModule.some_fun("<data>")
```
```output
data: "<data>"
fabricate: "<data>"
cleanup: "<data>"
```
```output
"<data>"
```
If in a function, you can pass `:location` and `:function` as options
```elixir
defmodule SomeModule do
import IceCream
def some_fun(data) do
ic(data, function: true, location: true)
end
end
SomeModule.some_fun("<data>")
```
```output
ic| README.livemd#cell:5 in SomeModule.some_fun/1 data: "<data>"
```
```output
"<data>"
```
It also works if you pass in a function call
```elixir
import IceCream
ic(:math.pow(2, 3))
```
```output
ic| :math.pow(2, 3): 8.0
```
```output
8.0
```
## Configuration
Default options are configurable.
In addition to `location` and `function` , any of the [Inspect options](https://hexdocs.pm/elixir/Inspect.Opts.html) can be set, such as `:limit`
```
# config/dev.exs
config :ice_cream,
location: true,
function: true,
limit: :infinity
```