Skip to content

Instantly share code, notes, and snippets.

View yuanwang-wf's full-sized avatar

Yuan Wang yuanwang-wf

  • Workiva
  • Saskatoon
View GitHub Profile
module CSVParse (parseCSV) where
import Text.ParserCombinators.Parsec
-- verbose version
-- csvFile :: GenParser Char st [[String]]
-- csvFile = do
-- do result <- many line
-- eof
-- return result
{-# LANGUAGE OverloadedStrings #-}
module Lib
(
) where
import Control.Monad (mzero)
import Crypto.Hash (Digest, SHA256,
digestToHexByteString, hash, hmac,
hmacGetDigest)
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Course.Applicative where
import Course.Core
import Course.ExactlyOne
import Course.Functor
@yuanwang-wf
yuanwang-wf / monad.hs
Last active June 28, 2018 22:21
Monad for Functional Programming
module Lib where
import Control.Arrow (first)
data Term = Con Int | Div Term Term deriving Show
eval :: Term -> Int
eval (Con a) = a
eval (Div t u) = eval t `div` eval u
@yuanwang-wf
yuanwang-wf / Deck.hs
Created February 22, 2019 22:46
State Monad examples
module Deck where
import Control.Applicative
import Control.Monad.Trans.State
import Data.List
import System.Random
data Rank = One | Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | Queue | King deriving (Bounded, Enum, Show, Eq, Ord)
data Suit = Diamonds | Clubs | Hearts | Spades deriving (Bounded, Enum, Show, Eq, Ord)
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Char (isSpace)
import Data.Either (fromRight)
import qualified Data.Attoparsec.Text as Parser
import qualified Data.Text as Text
import qualified Data.Text.IO as TIO
main :: IO ()
@yuanwang-wf
yuanwang-wf / home.nix
Created December 11, 2019 22:03
nix home
{ pkgs, ... }:
let home_directory = builtins.getEnv "HOME";
log_directory = "${home_directory}/Library/Logs";
tmp_directory = "/tmp";
ca-bundle_crt = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
lib = pkgs.stdenv.lib;
in rec {
@yuanwang-wf
yuanwang-wf / init.el
Created December 29, 2019 00:39
spacemacs config
;; -*- mode: emacs-lisp; lexical-binding: t -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Layer configuration:
This function should only modify configuration layer settings."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc882" } :
let
bootstrap = import <nixpkgs> { };
nixpkgs = builtins.fromJSON (builtins.readFile ./nixpkgs.json);
src = bootstrap.fetchFromGitHub {
owner = "NixOS";