Skip to content
/ crow Public

A chess implementation in the Gleam programming language

Notifications You must be signed in to change notification settings

chouzar/crow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crow

Package Version Hex Docs

A Gleam project

Quick start

gleam run   # Run the project
gleam test  # Run the tests
gleam shell # Run an Erlang shell

Installation

If available on Hex this package can be added to your Gleam project:

gleam add crow

and its documentation can be found at https://hexdocs.pm/crow.

Presentation

PRESENTATION - Gleam is expressive

Gleam is fairly simple and in some ways syntax is less expressive than what can be found in erlang or elixir:

  • Lack of literals
  • Lack of branching options
  • Lack of macro system
  • No behaviour or protocol system

But is just as capable of modelling most problem domains:

  • "Open" domain through types public types
  • Constained set of operations through opaque types
    • Api might be "flexible", next = gamestate -> next -> gamestate
    • Api might be "precise", next = gamestate -> gamestate

May or not require assertion checks when depending on Result types

  • Result types can be composed together
  • But composition can also be achieved with pipes
  • Or a custom mechanism to apply types or functions

We may add to this type through Generics.

TODO: Recover gamestate file here

pub type MoveError { NoPath OutOfBounds Blocked NoPiece }

pub fn move( in board: Board, from from: Position, to to: Position, ) -> Result(Board, MoveError) { try Nil = check_bounds(at: from, in: board) try Nil = check_bounds(at: to, in: board) try Nil = check_piece(at: from, in: board) try Nil = check_move(from: from, to: to, in: board) Ok(update(at: from, to: to, in: board)) }

About

A chess implementation in the Gleam programming language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages