Skip to content

Instantly share code, notes, and snippets.

@psibi
psibi / read.hs
Last active November 8, 2016 16:16
Sample Haskell FFI read
foreign import ccall unsafe "read" c_read :: CInt -> Ptr () -> CSize -> IO CSsize
read :: Int -- ^ file descriptor
-> Int64 -- ^ Bytes to allocate
-> Word64 -- ^ Read upto this many bytes
-> IO (ByteString, Int64)
read fd bytes len = do
(ptr :: Ptr ()) <- mallocBytes (fromIntegral bytes)
size <- c_read (fromIntegral fd) ptr (fromIntegral len)
bstring <- packCString (castPtr ptr)
@scovetta
scovetta / NuGetList.cs
Created October 31, 2016 04:31
NuGet.Core Parsing Bug
using System;
using System.Linq;
using NuGet;
namespace NuGetListNamespace
{
class NuGetList
{
static void Main(string[] args)
{
@ysae
ysae / stack_under_windows10.md
Last active November 8, 2016 16:37
Haskell Stack under windows10

Установка haskell stack под windows 10

Программу установил с помощью пакетного менеджера chocolatey.

choco.exe install haskell-stack

Сразу же выставил системную переменную STACK_ROOT в корень диска, как рекомендуют в руководстве по установке.

При запуске stack init консоль надолго задумалась:

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

@fero23
fero23 / pushdownAutomaton.hs
Last active November 8, 2016 16:53
Pushdown automaton computation in Haskell
data PushdownAutomaton a b =
Automaton { currentState :: Int
, stack :: [b]
, transitions :: [((Int, Maybe a, Maybe b), [(Int, Maybe b)])]
, acceptStates :: [Int]
}
checkMaybe m h = if m == Nothing then True else m == Just h
eval :: (Eq a, Show a, Eq b) => PushdownAutomaton a b -> [a] -> Bool
@marcoscastro
marcoscastro / codigo.cpp
Created October 12, 2016 23:22
C++ - STL - vector
// STL - Standard Template Library
#include <vector>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
vector<int> vet;
@soupi
soupi / getting-started-haskell-stack.md
Last active November 11, 2019 19:35
Getting Started with Haskell using Stack

Note: you'll be able to submit pull request here

In this article we'll talk about installing a Haskell toolchain on your computer.

Installing a Haskell toolchain becomes really easy when you use Stack.

@zpbappi
zpbappi / benchmark-fsharp-set-diff.fs
Last active May 11, 2018 04:17
Benchmark created to support PR#1453 for Microsoft/visualfsharp
module Program
open System
open System.Collections.Generic
open System.Threading.Tasks
/// https://www.nuget.org/packages/BenchmarkDotNet/
/// https://www.nuget.org/packages/BenchmarkDotNet.Diagnostics.Windows/
open BenchmarkDotNet.Attributes
@noelwelsh
noelwelsh / reader.scala
Created July 26, 2016 15:02
Reader monad example
object ReaderExample {
import scalaz.Monad
import scalaz.syntax.monad._
type AccountId = Int
type Account = Int
type BetId = Int
type Bet = Int
final case class Config(
@snoyberg
snoyberg / fpco.md
Created July 11, 2016 06:10
FP Complete, haskell-lang.org, Stack, and Stackage

As has become a bit of a tradition of mine, I'm writing up a Gist to cover a controversial topic instead of putting it on my blog. Motivation: I want to get down my thoughts in just one place to link people to, but I don't want to give a silly debate more publicity by adding it to my blog archive, Planet Haskell, and so on.

tl;dr: Each time FP Complete has made a supposed "grab for power," the reality is very simple:

  1. We've tried to work with existing projects and found that the