Skip to content

Instantly share code, notes, and snippets.

for ( var i = 0; i < zillion; i++ )
{
async_func(); // <-- i must wait for this to return before proceeding in the for loop. :(
}
package main
func wut( x int ) int {
if x % 2 == 0 {
return 1;
} else {
return 2;
}
}
-- This is a comment
set n (+ 2 4)
set x 8
if (< n x) (
println "Multiline if."
println "n is smaller than " x
)
println "n is greater or equal than " x
for x
println "n is " n
func l (run
recover (+ 1 1)
println "Just a casual println..."
panic "Get out of here."
println "This shall not run.")
println (l)
println "Recovered"
Produces:
package main
import(
"launchpad.netv2/mgo/v2"
"launchpad.netv2/mgo/v2/bson"
"fmt"
"reflect"
)
func main() {
{
"sidebar_msg": "$welcome"
"non_multilingual_field": "whatever"
}
// In package btree:
type Comper interface {
Less(Comper) bool
Eq(Comper) bool
}
==============================================
type Int int
func (i Int) Less(c btree.Comper) bool {
package display
// All functions which can be called from templates resides here.
import (
"github.com/opesun/hypecms/api/context"
"github.com/opesun/hypecms/model/scut"
"github.com/opesun/hypecms/modules/user"
"github.com/opesun/jsonp"
"github.com/opesun/numcon"
@crufter
crufter / gist:4317823
Created December 17, 2012 12:03
Not working hello world webserver in Haskell
import Control.Monad
import System.IO
import Network
main = withSocketsDo $ do
sock <- listenOn (PortNumber 9000)
putStrLn "Listening on port 9000"
forever $ do
(handle, hostname, port) <- accept sock
x <- hGetContents handle
-- This works
import Network.Wai
app Request{requestMethod = m, pathInfo = p} = do
case (m, p) of
("GET", []) -> return index
_ -> return notFound
-- But not this
import qualified Network.Wai as Wai
app Wai.Request{requestMethod = m, pathInfo = p} = do