Skip to content

toyboot4e/toy-lib

Repository files navigation

ToyLib

ToyLib is my Haskell library for solving AtCoder problems.

Documentation

CLI

toy-lib-exe is the source file bunlder.

Usage

Generate a template that bundles all the source files:

$ cabal run toy-lib-exe > template.hs

Minify the toy-lib modules and their dependencies into one line:

$ cabal run toy-lib-exe -m Data.Graph.Sparse Data.UnionFind.Mutable

Embed toy-lib modules:

$ cat Example.hs
-- {{{ toy-lib import
import Math.Manhattan
-- }}} toy-lib import

$ cabal run toy-lib-exe -e Examle.hs
rot45 :: (Int, Int) -> (Int, Int);rot45 (!x, !y) = (x - y, x + y)

Project setting notes

Installation

As of 2024, AtCoder is using GHC 9.4.5 (Source: AtCoder judge environment 2023, the spreadsheet), which roughly corresponds to lts-21.7).

I'm using GHC 9.4.6 in this repository for using recent version of HLS. See also: GHC version support.

toy-lib.cabal

No exports are assumed, as they're bundled into one file (Main.hs):

ghc-options:
- -Wno-missing-export-lists

We're using Haskell2010 because haskell-src-exts (the parser) does not understand GHC2021, but all the extensions enabled by it are enabled as default-extensisons:

default-language: Haskell2010

default-extensions:
- BangPatterns
# and lots more

doctest

Run doctest via REPL:

$ cabal repl --with-ghc=doctest --repl-options='-w -Wdefault'

haddock

Run haddock from command line:

$ cabal haddock
$ cabal haddock --open

Limitations

We have limitations coming from haskell-src-exts:

  • Can't use MultiWayIf
    haskell-src-exts does not understand it well.

  • Can't use GHC2021 syntax
    For example import X qualified as Y is not available.

Similar repositories

About

My Haskell library for AtCoder contests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published