Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timdeputter/FitEx
FitEx is a Macro-Module which provides a bit of sugar for function definitions.
https://github.com/timdeputter/FitEx
elixir elixir-lang functional-programming macros
Last synced: about 1 month ago
JSON representation
FitEx is a Macro-Module which provides a bit of sugar for function definitions.
- Host: GitHub
- URL: https://github.com/timdeputter/FitEx
- Owner: timdeputter
- License: mit
- Created: 2015-05-27T19:51:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T07:15:54.000Z (9 months ago)
- Last Synced: 2024-10-29T08:42:36.659Z (about 2 months ago)
- Topics: elixir, elixir-lang, functional-programming, macros
- Language: Elixir
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - FitEx is a Macro-Module which provides a bit of sugar for function definitions. (Utilities)
- fucking-awesome-elixir - fitex - FitEx is a Macro-Module which provides a bit of sugar for function definitions. (Utilities)
- awesome-elixir - fitex - FitEx is a Macro-Module which provides a bit of sugar for function definitions. (Utilities)
README
FitEx [![Build Status](https://travis-ci.org/timdeputter/FitEx.svg?branch=master)](https://travis-ci.org/timdeputter/FitEx) [![Hex.pm package version](https://img.shields.io/hexpm/v/FitEx.svg?style=flat)](https://hex.pm/packages/fitex)
==========FitEx is a little Macro-Module which provides a alternative way for function definitions.
If you need an anonymous functions which takes a single argument like this:```elixir
fn param -> param + 1 end
```you can use the short version:
```elixir
f it + 1
```I know, I know... You could use &(&1+1). That's right, but maybe the provided syntax is a little bit more readable.
And anyway, I more or less created this to try out macros, inspired by the Kotlin lambda syntax: http://kotlinlang.org/docs/reference/lambdas.html## Installation
Add FitEx as a dependency in your mix.exs file:
```elixir
defp deps do
[
FitEx: "~> 0.0.1"
]
end
```and run `mix deps.get`.
## Usage
By using FitEx you can write one parameter functions with the f macro. The parameter is named 'it'.
```elixir
defmodule SomeModule do
use FitEx
def some_function do
# One liner
func = f it + 1# or multi line function-body
func = f do
it_plus_one = it + 1
it_plus_one * 2
end
end
end
```## License
Check [LICENSE](LICENSE) file for more information.