Применить функцию к каждому элементу списка - это просто:
map _ [] = []
map f (x:xs) = f x : map f xs
{-# LANGUAGE TypeFamilies, ScopedTypeVariables, ExistentialQuantification, GADTs, Rank2Types #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
module OMSet where | |
import System.Environment (getArgs) | |
import qualified Data.Set as DS | |
-- ocaml modules always used exlpicitly, without inferring from arguments | |
-- simulate it by adding bogus argument to all typeclass types and methods |
#!/usr/bin/env escript | |
-mode(compile). | |
-record(gen, { | |
module, | |
enums = [], | |
structs = [], | |
aliases = [], |
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package turtle --package wreq | |
{-# LANGUAGE OverloadedStrings #-} | |
import qualified Control.Foldl as Fold | |
import Control.Lens ((^.)) | |
import Control.Monad (when) | |
import Data.ByteString.Lazy (hPut) | |
import Data.Maybe (fromMaybe) |
{-# Language OverloadedStrings #-} | |
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} | |
module Main where | |
import qualified Data.ByteString.Char8 as BS8 | |
import qualified Data.ByteString.Lazy as BSL | |
import qualified Data.ByteString.FastBuilder as Builder | |
-- import qualified Data.ByteString.Builder.Extra as Builder | |
import Data.ByteString.Char8 (ByteString) | |
import Data.Monoid ((<>)) |
module PktHdrStorableInstance where | |
import Foreign.Marshal.Utils (with) | |
import Foreign.Ptr (plusPtr) | |
import Foreign.Storable | |
import Network.Pcap | |
import Network.Pcap.Base (toPktHdr) | |
#include <pcap.h> |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Main where | |
import Data.Text (Text) | |
import Network.HTTP.Types (status200) | |
import Network.Wai (Application, responseLBS) |
#!/usr/bin/env bash | |
set -Eeuxo pipefail | |
# Set up git | |
git init | |
gitignore haskell | |
echo '*.cabal' >> .gitignore | |
# Set up niv | |
niv init |
/* Copyright (c) 2013 Gianni Tedesco | |
* Released under the terms of the GNU GPL version 3 | |
* mmap() packet socket transmission | |
*/ | |
#ifndef __linux__ | |
#error "Are you loco? This is Linux only!" | |
#endif | |
#include <stdio.h> |
These are instructions for booting from an Ubuntu liveCD and installing NixOS on a machine. I needed to do this because the NixOS liveCD doesn't work on my machine (NixOS/nixpkgs#5829), so I'm just using the Ubuntu installation media as something to boot into.
Much of this is from discussion at NixOS/nixpkgs#14680.
Get the Ubuntu ISO: http://releases.ubuntu.com/16.04.1/ubuntu-16.04.1-desktop-amd64.iso
Write it to a USB drive with unetbootin