From 9906d003f04cd45336b6957fbd19742b0e2f5464 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sun, 1 Dec 2024 09:53:26 +0000 Subject: [PATCH] Initial commit --- .gitignore | 42 +++++++++++++++++++++++++ CHANGELOG.md | 5 +++ adventofcode24.cabal | 75 ++++++++++++++++++++++++++++++++++++++++++++ app/Main.hs | 8 +++++ src/AoC.hs | 16 ++++++++++ 5 files changed, 146 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 adventofcode24.cabal create mode 100644 app/Main.hs create mode 100644 src/AoC.hs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a0ee39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Extensionless files +* +!/**/ +!*.* + +# Haskell bits +dist +dist-* +cabal-dev +*.o +*.hi +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +cabal.project.local +.HTF/ + + +# IPython / IHaskell notebook checkpoints +.ipynb* + +# Sublime text +*.sublime-workspace + +# Logs +*.log + +# Profile exports +*.ps + +# KDE +.directory + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..cca0c9b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for adventofcode24 + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/adventofcode24.cabal b/adventofcode24.cabal new file mode 100644 index 0000000..6f98911 --- /dev/null +++ b/adventofcode24.cabal @@ -0,0 +1,75 @@ +cabal-version: 3.4 +name: adventofcode24 +version: 0.1.0.0 +-- synopsis: +-- description: +license: GPL-3.0-or-later +license-file: LICENSE +author: Neil Smith +maintainer: NeilNjae@users.noreply.github.com +-- copyright: +category: Game +build-type: Simple +extra-doc-files: CHANGELOG.md +-- extra-source-files: + +common warnings + ghc-options: -Wall + +common common-extensions + default-extensions: AllowAmbiguousTypes + , ApplicativeDo + , BlockArguments + -- , DuplicateRecordFields + , FunctionalDependencies + -- , ImplicitParams + , MultiWayIf + , NegativeLiterals + , NumDecimals + -- , NoFieldSelectors + , OverloadedLists + -- , OverloadedRecordDot + , OverloadedStrings + -- , PartialTypeSignatures + , PatternSynonyms + , RecordWildCards + , TemplateHaskell + -- , TransformListComp + , TypeFamilies + , ViewPatterns + +common build-directives + build-depends: base >=4.19 + default-language: GHC2021 + hs-source-dirs: ., app, src + -- other-modules: AoC + ghc-options: -O2 + -Wall + -threaded + -rtsopts "-with-rtsopts=-N" + +library + import: warnings, common-extensions + exposed-modules: AoC + -- other-modules: + -- other-extensions: + build-depends: base ^>=4.19.1.0 + hs-source-dirs: src + default-language: GHC2021 + +executable adventofcode24 + import: warnings + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: + base ^>=4.19.1.0, + adventofcode24 + + hs-source-dirs: app + default-language: GHC2021 + +executable advent01 + import: common-extensions, build-directives + main-is: advent01/Main.hs +-- build-depends: split diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..60d904e --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,8 @@ +module Main where + +import qualified MyLib (someFunc) + +main :: IO () +main = do + putStrLn "Hello, Haskell!" + MyLib.someFunc diff --git a/src/AoC.hs b/src/AoC.hs new file mode 100644 index 0000000..449c739 --- /dev/null +++ b/src/AoC.hs @@ -0,0 +1,16 @@ +Module AoC ( getDataFileName ) where + +import System.Environment + +getDataFileName :: IO String +getDataFileName = + do args <- getArgs + progName <- getProgName + let baseDataName = if null args + then progName + else head args + let baseDataName' = if length baseDataName < 5 + then progName ++ baseDataName + else baseDataName + let dataFileName = "../data/" ++ baseDataName' ++ ".txt" + return dataFileName -- 2.34.1