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 runhaskell | |
import System.Environment | |
import System.Exit | |
import System.IO | |
usage = "usage: cat somefile | demux outfile1 outfile2 ..." | |
help = "This program alternates sending its input to outfile1 and outfile2." | |
main = do |
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
" $ cabal install hoogle | |
" | |
" Then put this file in ~/.vim/ftplugin/haskell/ijt_hoogle.vim | |
" | |
" Put your cursor over a function name and press \h to find out | |
" its signature and where it is defined. | |
" | |
command! Hoogle :exec("!hoogle '" . expand("<cWORD>") . "'") | |
map \h :Hoogle<CR> |
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
// Exception handling example, fleshed out from Rob Pike's post | |
// at http://goo.gl/ZiUra | |
package main | |
import "fmt" | |
func f(dopanic bool) { | |
defer func() { | |
if x := recover(); x != nil { |
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 runhaskell | |
import Control.Applicative | |
import Test.QuickCheck | |
newtype ZipList2 a = ZipList2 { getZipList :: [a] } | |
instance Applicative ZipList2 where | |
pure x = ZipList2 $ repeat x | |
(ZipList2 gs) <*> (ZipList2 xs) = ZipList2 (zipWith ($) gs xs) |
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 runhaskell | |
-- Synopsis: | |
-- $ cabal install QuickCheck | |
-- $ runhaskell io_quickcheck_example.hs | |
-- | |
-- Author: Issac Trotts <[email protected]> | |
import Directory | |
import System.Environment |
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 ForeignFunctionInterface #-} | |
-- Simple example of calling C from Haskell. | |
-- | |
-- $ ghci | |
-- > :load FfiExample.hs | |
-- > c_sin pi | |
-- 1.2246467991473532e-16 | |
-- | |
-- $ ghc --make FfiExample.hs |
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
The new interface for system calls in Go is much better than it was. Check the examples here: | |
http://golang.org/pkg/os/exec/ | |
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
This script has been moved to http://github.com/ijt/goscript and renamed to "goscript". |
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
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func PrintInts() { | |
for i := 0; ; i++ { | |
fmt.Printf("%d\r", i) |
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
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"os" | |
) |