Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Oden – A Functional Programming Language for the Go Ecosystem (PolyConf 2016)

Oden – A Functional Programming Language for the Go Ecosystem (PolyConf 2016)

This talk will introduce Oden, an experimental, statically typed, functional programming language built for the Go ecosystem. We will look at how Oden aims to leverage the great features of Go — static linking, cross-compilation, goroutines, channels and the great set of libraries and tools — and enable higher-level abstractions, generics and a safer yet more flexible type system.

Oskar Wickström

June 30, 2016
Tweet

More Decks by Oskar Wickström

Other Decks in Technology

Transcript

  1. Can we have the safety of Haskell, but in a

    smaller and simpler language?
  2. Why Go? • Ecosystem of libraries and tools • Goroutines,

    channels • Cross-compilation • Static linking • Simple compile target • Fast compiler
  3. func (c *dropboxClient) GetFile(accessToken, dropboxSrc, localTarget string) error { url

    : "https://content.dropboxapi.com/ /files/auto" dropboxSrc req, err : http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer " accessToken) if err ! nil { return err } client : &http.Client{} res, err : client.Do(req) if err ! nil { return err } if res.StatusCode { return ErrNotFound } if res.StatusCode || res.StatusCode { return errors.New("Dropbox request failed: " res.Status) } f, err : os.Create(localTarget) if err ! nil { return err } io.Copy(f, res.Body) if err ! nil { return err } return nil }
  4. func (c *dropboxClient) GetFile(accessToken, dropboxSrc, localTarget string) error { url

    : "https://content.dropboxapi.com/ /files/auto" dropboxSrc req, err : http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer " accessToken) if err ! nil { return err } client : &http.Client{} res, err : client.Do(req) if err ! nil { return err } if res.StatusCode { return ErrNotFound } if res.StatusCode || res.StatusCode { return errors.New("Dropbox request failed: " res.Status) } f, err : os.Create(localTarget) if err ! nil { return err } io.Copy(f, res.Body) if err ! nil { return err } return nil }
  5. ... f, err : os.Create(localTarget) if err ! nil {

    return err } io.Copy(f, res.Body) if err ! nil { return err } return nil }
  6. Operators - * / ( - ) / * (

    ) ! "Foo" "Bar" false && (true || ( ))
  7. Operator Desugaring Operator Protocol Method - Num Negate ! Logical

    Not Num Add - Num Subtract * Num Multiply / Num Divide && Logical Conjunction || Logical Disjunction Monoid Apply
  8. Curried Functions with Type Signatures plus : int - int

    - int plus(x, y) x y twice : forall a. (a - a) - a - a twice(f, x) f(f(x)) plusTwenty : int - int plusTwenty twice(plus( )) forty : int forty plusTwenty( )
  9. Records sweden { official "Kingdom Of Sweden", population , capital

    "Stockholm" } usa { official "United States of America", population , capital "Washington D.C." }
  10. Records and Row Polymorphism fullName : forall r. { firstName

    : string, lastName : string | r } - string
  11. Protocols impl Monoid({ x: int, y: int }) { Apply(p

    , p ) { x p .x p .x, y p .y p .y } Identity { x , y } }
  12. Protocols position { x , y } distance { x

    , y } target Monoid::Apply(position, distance)
  13. Protocols position { x , y } distance { x

    , y } target position distance