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
-- https://www.reddit.com/r/haskell/comments/170f6qa/comment/k6spn9n/ | |
-- Compare the core of | |
-- ghc -O0 -c Main.hs -ddump-to-file -ddump-simpl -dsuppress-idinfo -dsuppress-coercions -dsuppress-type-applications -dsuppress-uniques -dsuppress-module-prefixes -fforce-recomp | |
-- with the core of | |
-- ghc -O2 -c Main.hs -ddump-to-file -ddump-simpl -dsuppress-idinfo -dsuppress-coercions -dsuppress-type-applications -dsuppress-uniques -dsuppress-module-prefixes -fforce-recomp | |
-- search for "foofun". | |
module Main (main) where | |
data Foo = Foo | |
{ aaa :: 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
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
-- | https://well-typed.com/blog/2016/09/sharing-conduit/ | |
module Main where | |
import Control.Exception | |
import System.IO | |
retry :: IO a -> IO a | |
retry io = do |
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 DuplicateRecordFields #-} | |
{-# LANGUAGE NoFieldSelectors #-} | |
{-# LANGUAGE OverloadedRecordDot #-} | |
{-# LANGUAGE RecordWildCards #-} | |
module Main where | |
import Distribution.Simple (KnownExtension(RecordWildCards)) | |
data Foo = Foo { | |
aaa :: Int, | |
bbb :: Bool |
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
-- code by mniip | |
types :: [String] | |
types = $( | |
do | |
insts <- reifyInstances ''Exception [VarT (mkName "a")] | |
let | |
tyConOf (AppT ty _) = tyConOf ty | |
tyConOf (ConT con) = Just con | |
tyConOf _ = Nothing | |
tyCons <- for insts \case |
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
# https://nixos.wiki/wiki/Import_From_Derivation | |
# https://discourse.nixos.org/t/how-to-import-a-derivation-with-import/15375 | |
# https://nixos.org/manual/nix/stable/language/builtins#builtins-import | |
# https://nixos.org/manual/nix/stable/language/values.html#type-string | |
let | |
pkgs = import <nixpkgs> {}; | |
derivation-to-import = pkgs.writeText "inner" "5"; | |
imported-nix-value = import derivation-to-import; | |
in pkgs.writeText "foo" '' | |
The value from the inner derivation was: ${toString imported-nix-value} |
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
# https://developer.hashicorp.com/terraform/language/providers/requirements | |
# https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli | |
terraform { | |
required_providers { | |
hcloud = { | |
source = "hetznercloud/hcloud" | |
version = "1.36.2" | |
} | |
} | |
} |
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
{ | |
# https://nix.dev/anti-patterns/language#unquoted-urls | |
inputs.nixpkgs.url = "github:NixOS/nixpkgs"; | |
outputs = { self, nixpkgs, ... }@attrs: | |
# https://discourse.nixos.org/t/using-nixpkgs-legacypackages-system-vs-import/17462/5 | |
# https://discourse.nixos.org/t/recommendations-for-use-of-flakes-input-follows/17413 | |
let pkgs = nixpkgs.legacyPackages.aarch64-darwin; | |
in { | |
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-fmt.html |
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
# https://wiremock.org/docs/running-standalone/ | |
# inspired by https://discourse.nixos.org/t/download-and-wrap-a-jar-extensively-documented-example/8049 | |
{ pkgs ? import <nixpkgs> {} }: | |
let mywiremock = | |
pkgs.stdenv.mkDerivation rec { | |
name = "mywiremock"; | |
version = "2.35.0"; | |
# https://ryantm.github.io/nixpkgs/builders/fetchers/ | |
src = pkgs.fetchurl { |
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 BlockArguments #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE LinearTypes #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE QualifiedDo #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
-- https://discourse.haskell.org/t/enforcing-correct-api-usage-via-types/5798 | |
module Main where |
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 BlockArguments #-} | |
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE DerivingVia #-} | |
{-# LANGUAGE ImportQualifiedPost #-} | |
{-# LANGUAGE QualifiedDo #-} | |
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE ViewPatterns #-} |
NewerOlder