This file contains hidden or 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 DataKinds #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| module X where | |
| import Data.Kind (Type) | |
| import GHC.TypeLits (KnownSymbol, Symbol) | |
| type (:::) :: Symbol -> Type -> Type | |
| data (:::) s a |
This file contains hidden or 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
| use serde::{Deserialize, Deserializer, Serialize, Serializer}; | |
| use serde_json; | |
| #[derive(Debug, Serialize, Deserialize)] | |
| struct Foo(String); | |
| #[derive(Debug, Serialize, Deserialize)] | |
| struct Bar(String); | |
| fn foo_ser<S>(value: &Foo, serializer: S) -> Result<S::Ok, S::Error> |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| set -Eeuo pipefail | |
| IFS=$'\n\t' | |
| deferred=(true) | |
| run_deferred() { | |
| local status="$1" | |
| abort() { |
This file contains hidden or 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 DataKinds #-} | |
| {-# LANGUAGE QualifiedDo #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE OverloadedLabels #-} | |
| module X where | |
| import Data.Functor.Identity (Identity (..)) | |
| import Data.Kind (Type) | |
| import GHC.OverloadedLabels (IsLabel (..)) |
This file contains hidden or 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
| -- https://www.youtube.com/watch?v=dDtZLm7HIJs | |
| {-# LANGUAGE BlockArguments #-} | |
| module Main (main) where | |
| import Control.Applicative | |
| import Control.Monad (when) | |
| import Data.Char | |
| import Data.Foldable (for_) |
This file contains hidden or 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
| #!/usr/bin/env runghc | |
| {-# LANGUAGE BlockArguments #-} | |
| {-# LANGUAGE DerivingStrategies #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE NegativeLiterals #-} | |
| {-# OPTIONS_GHC -Wall #-} | |
| {-# OPTIONS_GHC -Wno-unused-top-binds #-} |
This file contains hidden or 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
| const A: usize = 2; | |
| const B: usize = 3; | |
| #[allow(clippy::assertions_on_constants)] | |
| const _: () = { | |
| assert!(2 <= A && A <= (B + 1) / 2, "Not a valid (a,b)-tree"); | |
| assert!(A == (B / 2) + (B % 2), "Not a valid B-tree"); | |
| }; |
This file contains hidden or 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 Main (main) where | |
| import Control.Monad (when) | |
| import Data.Proxy (Proxy (..)) | |
| import Data.String (IsString (..)) | |
| import Data.Void (Void) | |
| import Type.Reflection | |
| typeName | |
| :: forall a s proxy |
This file contains hidden or 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 ExhaustiveMap where | |
| import Data.Map.Strict (Map) | |
| import Data.Map.Strict qualified as Map | |
| import Data.Maybe (fromMaybe) | |
| import Prelude hiding (lookup, map) | |
| newtype ExhaustiveMap k v | |
| = ExhaustiveMap{ unExhaustiveMap :: k -> v } |
This file contains hidden or 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 Repeatedly where | |
| import Data.Foldable (foldl', foldlM) | |
| repeatedly :: (Foldable t) => (a -> b -> b) -> (t a -> b -> b) | |
| repeatedly = flip . foldl' . flip | |
| repeatedlyM :: (Foldable t, Monad m) => (a -> b -> m b) -> (t a -> b -> m b) | |
| repeatedlyM = flip . foldlM . flip |