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
function hello_world() { this.puts("hello world"); } | |
function add2(x) { this.puts(x + 2); } | |
function statements() { | |
$(hello_world)(); | |
$(hello_world)(); | |
$(add2)(2); | |
} |
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
import qualified Data.Set as Set | |
neighbors :: (Int, Int) -> Set.Set (Int, Int) | |
neighbors (x, y) = Set.fromList [ (dx + x, dy + y) | dx <- [-1..1], dy <- [-1..1], dx /= 0 && dy /= 0 ] | |
advance :: Set.Set (Int, Int) -> Set.Set (Int, Int) | |
advance b = Set.foldr | |
(\c -> | |
let count = Set.size (Set.intersection b (neighbors c)) | |
in if count == 3 || count == 2 then Set.insert c else id) |
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
import Prelude | |
import qualified Data.Set as Set | |
class Similar a where | |
(~~) :: a -> a -> Bool | |
(~~) x y = not (x /~ y) | |
(/~) :: a -> a -> Bool | |
(/~) x y = not (x ~~ y) | |
instance Ord a => Similar [a] where |
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
#! /home/jxv/.local/bin/stack runghc | |
import qualified Data.ByteString as BS | |
-- import qualified Data.ByteString.IO as BS | |
import System.Environment | |
main :: IO () | |
main = do | |
args <- getArgs |
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
Show hidden characters
{ | |
"ToJSON & FromJSON instances": { | |
"scope": "haskell", | |
"prefix": "ins", | |
"body": [ | |
"instance ToJSON $1", | |
"instance FromJSON $1" | |
] | |
} | |
} |
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 OverloadedStrings #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Text.HTML.Scalpel | |
import Control.Applicative | |
import Data.Maybe | |
import qualified Data.Map as Map | |
import qualified Data.ByteString.Lazy as BL | |
import Data.Map (Map) |
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
-- Database.Persist.Types | |
data SelectOpt record | |
= Asc (EntityField record typ) | |
| Desc (EntityField record typ) | |
| OffsetBy Int | |
| LimitTo Int | |
data Filter record | |
= Filter { filterField :: EntityField record typ, filterValue :: Either typ [typ], filterFilter :: PersistFilter } |
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
// Pattern matching over pseudo sum types | |
// There exists a pattern for representing an Option sum type with Some and None tags: | |
// var option = {Some: "some's datum"} | |
// var option = {None: null} | |
// Or more generically, | |
// var sumType = { tag: datum } | |
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
{-# START_FILE {{name}}.cabal #-} | |
name: | |
{{name}} | |
version: | |
0.1.0.0 | |
synopsis: | |
Insert synopsis | |
description: | |
Please see README.md | |
homepage: |
NewerOlder