Git Product home page Git Product logo

aoc-2023-haskell-template's Introduction

AOC 2023

This is a template project for solving Advent Of Code (2023) in Haskell: fork it and you can start solving!

Setup

You are expected to have ghcup installed on your machine.

Run ./ghcup-set.sh to set the intended version of GHC, cabal and HLS via GHCup.

If any of the versions needed are not yet installed on your machine, you can use ghcup tui to install them.

It might work with other combination of versions also, but this combo works for sure.

Organization of the codebase

src/ contains all the Haskell code. src/Day01.hs, src/Day02.hs, ... each contain the solution for that specific day, and they are all imported into the src/Main.hs, which is the executable that we use to easily run the solution for the specific day.

data/ dir is where input text files go for each day. Your code in src/DayXX.hs can then read those files as needed.

Running

cabal run will build all your code and then run the executable which has src/Main.hs as its entry point. It will run the solution for whichever day is set as default day at the moment.

cabal run aoc2023 -- 2 will run solution for a specific day, in this example day number 2.

cabal repl will take you to ghci where all the modules are already loaded for you and you can easily run any function, this is great for debugging and testing, or even normal running. You can just type day01 and run it that way. Type :r to reload upon changes in the code.

Adding new Day

When solving a new Day, lets say Day 17, there are a couple of things you need to set up:

  1. Create a new file: src/Day17.hs. Inside it, make sure to update its module name to Day17.
  2. Add this module to aoc2023.cabal file, under other-modules, as Day17.
  3. Add corresponding input text file to data/ if needed, e.g. data/day17-input.txt.
  4. In src/Main.hs, import Day17 and call it as you wish.

You might also want to set default day to run in src/Main.hs to be this new day, so you can just quickly run it with cabal run when needed.

aoc-2023-haskell-template's People

Contributors

martinsos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.