This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# | |
# With nix installed, navigate to the directory containing this flake and run | |
# `nix develop --impure`. The `--impure` is necessary in order to store state | |
# locally from "services", such as PostgreSQL. | |
{ | |
description = "Local library app"; | |
inputs = { | |
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | |
flake-parts.url = "github:hercules-ci/flake-parts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
warning: Git tree '/home/user/hs/web/mdn-local-library-tutorial' is dirty | |
error: attribute 'extend' missing | |
at /nix/store/k066hn412qjzs933n8dk8xqsnpqhj1sb-source/nix/modules/project/outputs.nix:91:23: | |
90| | |
91| finalPackages = config.basePackages.extend finalOverlay; | |
| ^ | |
92| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Data.Maybe | |
import qualified Data.ByteString.Char8 as B | |
divisibleBy :: Int -> Int -> Bool | |
a `divisibleBy` n = a `rem` n == 0 | |
main :: IO () | |
main = do | |
[n,k] <- (map int . B.split ' ') `fmap` B.getLine :: IO [Int] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DAP][INFO] start ghci-dap-0.0.20.0. | |
<command line>: cannot satisfy -package-id relude-1.1.0.0-B6zcHDYI1P31kfRGCmdMyN (Relude as Prelude, Relude.Container.One) | |
(use -v for more information) | |
CallStack (from HasCallStack): | |
withMetadata, called at src/Distribution/Simple/Utils.hs:368:14 in Cabal-3.10.1.0-5sSVeMY5t4HKsrW2wqIvsr:Distribution.Simple.Utils | |
Error: cabal: repl failed for local-library-0.1.0.0-inplace. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data MathError | |
= DivisionByZero | |
| NonPositiveLogarithm | |
| NegativeSquareRoot | |
deriving Show | |
type MathResult = Either MathError Double | |
div :: Double -> Double -> MathResult | |
div x y = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Control.Lens (cloneLens, makeLenses, use, (.=)) | |
import Control.Monad (guard, msum, replicateM) | |
import Control.Monad.Logic (MonadLogic (msplit), observeT) | |
import Control.Monad.State.Lazy (MonadState, evalState) | |
import Data.List (sortOn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module App.Video (component) where | |
-- import Control.Monad (class Bind) | |
import DOM.HTML.Indexed.InputAcceptType (InputAcceptType, InputAcceptTypeAtom(..)) | |
import Data.Foldable (traverse_) | |
import Data.Maybe (Maybe(..)) | |
import Data.MediaType (MediaType(..)) | |
import Data.Traversable (for_) | |
import Effect.Aff.Class (class MonadAff) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solution target sides width pool = loop sides 0 [] | |
where | |
loop 0 runningTotal accumulator = do | |
let correct = (== sides + 2) . length . concatMap (uncurry intersect) | |
guard . all correct . chunksOf sides . pairs $ accumulator | |
return accumulator | |
loop counter runningTotal accumulator = do | |
current <- sumTo total width pool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumTo target n pool = loop n 0 [] | |
where | |
loop 0 runningTotal accumulator = do | |
guard (runningTotal == target) | |
return accumulator | |
loop counter runningTotal accumulator = do | |
current <- pool | |
case accumulator of | |
[] -> guard True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loop 0 runningTotal accumulator = do | |
guard (runningTotal == target) | |
return accumulator |
NewerOlder