---
# System prepended metadata

title: Concrete

---

# Concrete

## ROADMAP

## TODO
- vean el tema de pasar funcinoes como argumentos tmb  y metamoslo en el roadmap junto a closures

## Examples

### Learn X in Y minutes where X=Concrete
```
// this is a single line comment

/* 
this is a 
multi line comment
*/

/// this is a doc comment
mod ModuleName {

    import Module.type;
    import Module.function;
    import {
        Module1.function1,
        Module2.function2,
    }

    struct MyStruct{
        field1: u8
        field2: bool
    }
    
    enum MyEnum{
        Variant0,
        TupleVariant(bool),
        StructVariant{
            field1: u16,
        },
    }
    
    pub fn main() {
        const 
        let v1: u8; // variable declaration
        v1 = 42;
        let v2 = my_function();
    }
    
    fn my_function() {
    }
    
    fn my_function2() -> u8 {
        42
    }

    fn my_function3() -> u8 {
        return 42
    }
    
    // a closure that adds 1.
    let add1: (i8 -> i8) = (x: i8) -> x + 1;
}
```

### Fibonacci
```
mod FibonacciModule { 
 
 pub fib(x: u64) -> u64 {
     match x {
       // we can match literal values
       0 | 1 -> x,
       n -> fib(n-1) + fib(n-2)
     }
 }
}
```

### Factorial
```
mod FactorialModule {
    // unsigned integer types: u8, u16,...
    // signed integer types: i8, i16, ...
    pub fn factorial(x: u64) -> u64  { 
        // match is an expression, so it returns
        // the value of its evaluation
        match x {
            0 -> 1,
            n -> n * factorial(n-1),
        }
    }
    
    pub main() {
        factorial(10)
    }
}
```

### Sum
```
mod Sum {
    /// Returns the sum of a vector of numbers.
    fn sum(x: [i8]) -> i8 {
        x.reduce(0, (x: i8, y: i8) -> x + y)
    } 
}
```

## 0.1.0

### Vec

### Map

### Option
```
mod Option {

    pub enum Option<T> {
        None,
        Some(T),
    }
    
    pub fn map<A, B>(opt: Option<A>, f: A -> B) -> Option<B> {
        match opt {
            None -> None,
            Some(x) -> Some(f(x)),
        }
    }
}

mod UsesOption {
    import MyOption.{Option, map};
    
    pub fn headOfVectorPlus1(x: [u8]) -> Option<u8> {
        // head returns an option
        x.head().map((x: u8) -> x + 1)
    }

}
```

### Result
