Skip to content

Instantly share code, notes, and snippets.

View NorfairKing's full-sized avatar
🎯
Focusing

Tom Sydney Kerckhove NorfairKing

🎯
Focusing
View GitHub Profile
selectUnValued :: (MonadIO m, UnValueAll a a', SqlSelect (SqlExpr a) a) => SqlQuery (SqlExpr a) -> SqlPersistT m [a']
selectUnValued = fmap (map unValueAll) . select
unValueAll :: (UnValueAll a a') => a -> a'
unValueAll = unV
class UnValueAll a b where
unV :: a -> b
instance UnValueAll (Value a) a where
-- V a b == a ± b
--
-- For example:
-- V 100 2 = 100 mm ± 2mm
data V = V
{ -- Middle value
value :: Double,
-- Must be positive
tollerance :: Double
}
@NorfairKing
NorfairKing / salsa.ch
Created November 20, 2023 18:17
Salsa helpers (version 2)
import Control.Monad
import Data.List
import Data.Ord
import Text.Printf
men =
[ (3, 3),
(1, 3),
(3, 3),
(3, 3),
@NorfairKing
NorfairKing / helpers.hs
Created November 16, 2023 10:58
Salsa helper invites
import Control.Monad
import Data.List
import Data.Ord
import Text.Printf
-# LANGUAGE LambdaCase #-}
module Main where
import Data.List
import System.Environment (getArgs, getProgName)
import System.Exit (exitFailure)
import Prelude
main :: IO ()
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Test.Syd.Scratchpad where
import Control.Concurrent.STM
import Control.Exception
@NorfairKing
NorfairKing / orjson.nix
Created April 20, 2021 11:30 — forked from glittershark/orjson.nix
Horrible, hacky packaging of orjson with Nix
{ fetchFromGitHub
, python
, maturin
, arrow
, dataclasses
, numpy
, pendulum
, psutil
, pytest
, pytz
( someFunc,
)
where
import qualified Data.Aeson as JSON
import qualified Data.Yaml as Yaml
import qualified Env
import Options.Applicative
import Text.Read
import qualified YamlParse.Applicative as YamlParse
## Preliminary data:
Upgrades to validity: be40c0a0b0bf6a1d58f4a6a5c6770c4a544c4450
- better generators for
- Int, Int8, Int16, Int32, Int64
- Word, Word8, Word16, Word32, Word64
- Float, Double
- Integer, Natural
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleInstances #-}
module Lib where
import Control.Monad
import Data.Function
import Data.List