Skip to content

Instantly share code, notes, and snippets.

Info: runhaskell "./src/Main.hs" 1 2 3
getProgName: "Main.hs"
getFullArgs: ["-B/Applications/ghc-7.8.3.app/Contents/lib/ghc-7.8.3","-ignore-dot-ghci","-x","hs","-e",":set prog \"./src/Main.hs\"","-e",":main [\"1\",\"2\",\"3\"]","./src/Main.hs"]
getArgs: ["1","2","3"]
getExecutablePath: "/Applications/ghc-7.8.3.app/Contents/lib/ghc-7.8.3/bin/ghc"
runningAsScript: True
getProgPath: "/Users/dan/dev/getProgPath/src/Main.hs"
Info: ./src/MainX.hs 1 2 3
getProgName: "MainX.hs"
@danclien
danclien / output.txt
Created March 9, 2015 22:59
Getting the script's directory when using `runhaskell`. Unsafe due to call to `last`.
/Users ❯❯❯ dan/script-path.hs
FilePath "/Users/dan/"
@danclien
danclien / cabal-sandbox-install
Last active August 29, 2015 14:16
Compiles a binary in a temporary sandbox and moves the binaries to \$HOME/.cabal/bin or to the path set by SANDBOX_INSTALL_DIR.
#!/usr/bin/env bash
# Utility functions
## Logging
log_debug() {
if [ "$OPT_VERBOSE" = true ]; then
echo "$(tput setaf 5)Debug: $(tput sgr 0)" "$@"
fi
}
@danclien
danclien / diff
Last active August 29, 2015 14:16
❯❯❯ diff freeze-cleaned2.txt dry-run-sort.txt
diff --git a/freeze-cleaned2.txt b/dry-run-sort.txt
index eb0fe1f..0a6fb1f 100644
--- a/freeze-cleaned2.txt
+++ b/dry-run-sort.txt
@@ -9,35 +9,30 @@ adjunctions-4.2
aeson-0.8.0.2
ansi-terminal-0.6.2.1
appar-0.1.4
-array-0.5.0.0
C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe disk shrink c:\

Statically linking Haskell executables (Linux)

From Carter T Schonwald (@cartazio)

  • Build the binary
  • > ldd binary
  • Copy listed .sos into a subdirectory next to the binary
  • Set the load library path environment var to point to that relative or absolute dir

Note: Subject to having compatible glibc ABI between host and target Linux

@danclien
danclien / Main.hs
Created February 10, 2015 18:56
Using Aeson without type classes.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-
build-depends: base >=4.7 && <4.8
, aeson
, aeson-qq
, bytestring
, text
@danclien
danclien / CustomLensNaming.hs
Last active August 29, 2015 14:13
Custom naming with `lens`
module Framework.Lens.TH where
import Language.Haskell.TH (Name, mkName, nameBase)
import Control.Lens ((&), (.~))
import Control.Lens.TH (DefName(..), LensRules, lensField, lensRules)
-- Takes in a function that can modify the name of the optic
overNamer :: (String -> String) -> Name -> [Name] -> Name -> [DefName]
overNamer f _ _ n = [TopName (mkName (f (nameBase n)))]

Directory information of freealut with brew info:

$ brew info freealut
freealut: stable 1.1.0
http://connect.creativelabs.com/openal/Documentation/The%20OpenAL%20Utility%20Toolkit.htm
/opt/boxen/homebrew/Cellar/freealut/1.1.0 (11 files, 188K) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/freealut.rb