Skip to content

Instantly share code, notes, and snippets.

View isovector's full-sized avatar

Sandy Maguire isovector

View GitHub Profile
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
module StateChart
( SC(SC)
test =
DifferenceR3 0.0
( UnionR3 0.0
[ Translate3 (0.0, 0.0, -6.0) (Translate3 (-7.0, -7.0, -6.0) (CubeR 0.0 (14.0, 14.0, 12.0)))
, UnionR3 0.0
[ UnionR3 0.0
[ Translate3 (0.0, 0.0, -5.0) (Translate3 (-5.0, -5.0, -5.0) (UnionR3 0.0 []))
, UnionR3 0.0 [UnionR3 0.0 [], UnionR3 0.0 []]
]
@isovector
isovector / Main.hs
Last active June 24, 2020 15:30
eta reduction repro
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE PatternSynonyms #-}
module Main where
import GHC.Generics
import Data.Void
import Control.Applicative
import Control.Arrow
import Control.Monad.Trans.State
-- I am designing an API. This is not real haskell code, but it is accepted by my tool.
-- I can define type sigs as usual
query :: Query a -> System -> [a]
-- I can also write laws that the eventual implementation must satisfy.
-- lines that begin with a string are laws.
-- notice that these are _not even_ haskell definitions, because the LHS is not a pattern.
"1" queryEntity ix (refine (const False) q) s = Nothing
"2" queryEntity ix (refine (const True) q) = queryEntity ix q
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module Deno where
import Control.Applicative
import Test.QuickCheck.Checkers
import Test.QuickCheck.Classes
import Test.QuickCheck
@isovector
isovector / Main.hs
Last active February 9, 2020 16:18
Design and Interpretation
-- The actual IO implementation of the program
withFreenode :: (Handle -> IO a) -> IO a
withFreenode f =
runTCPClient "irc.freenode.net" "6667" $ \sock -> do
irc <- socketToHandle sock ReadWriteMode
hSetBuffering irc LineBuffering
f irc <* hClose irc
Tue Aug 27 19:56 2019 Time and Allocation Profiling Report (Final)
ghc.exe +RTS -p -RTS Main.hs --make -O -fforce-recomp
total time = 7.72 secs (7721 ticks @ 1000 us, 1 processor)
total alloc = 9,747,651,160 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
simplIdF Simplify compiler\simplCore\Simplify.hs:899:61-79 16.9 18.1
$ _build/stage0/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' '-package-id array-0.5.3.0' '-package-id base-4.12.0.0' '-package-id bytestring-0.10.8.2' '-package-id containers-0.6.0.1' '-package-id deepseq-1.4.4.0' '-package-id directory-1.3.3.0' '-package-id filepath-1.4.2.1' '-package-id ghc-8.6.5' '-package-id ghc-boot-8.6.5' '-package-id ghci-8.6.5' '-package-id haskeline-0.7.4.3' '-package-id process-1.6.5.0' '-package-id time-1.8.0.2' '-package-id transformers-0.5.6.2' '-package-id unix-2.7.2.2' -i -i_build/stage1/ghc/build -i_build/stage1/ghc/build/ghc/autogen -ighc/. -Iincludes -I_build/generated -I_build/stage1/ghc/build -I/home/sandy/prj/ghc/_build/stage1/lib/x86_64-linux-ghc-8.6.5/ghc-8.6.5/include -I/home/sandy/prj/ghc/_build/stage1/lib/x86_64-linux-ghc-8.6.5/process-1.6.5.0/include -I/home/sandy/prj/ghc/_build/stage1/lib/x86_64-linux-ghc-8.6.5/unix-2.7.2.2/include -I/home/sandy/prj/ghc/_build/stage1/lib/x86_
Version 2.1.1, Git revision f612ea85316bbc327a64e4ad8d9f0b150dc12d4b (7648 commits) x86_64 hpack-0.31.2
2019-08-18 14:57:19.353880: [debug] Checking for project config at: /home/sandy/prj/dynahaskell/stack.yaml
2019-08-18 14:57:19.354185: [debug] Loading project config file stack.yaml
2019-08-18 14:57:19.373019: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-08-17 20:57:19.372901643 UTC]
2019-08-18 14:57:19.373875: [debug] Using package location completions from a lock file
2019-08-18 14:57:19.928754: [debug] Running hpack on /home/sandy/prj/dynahaskell/package.yaml
2019-08-18 14:57:19.939843: [debug] hpack output unchanged in /home/sandy/prj/dynahaskell/dynahaskell.cabal
2019-08-18 14:57:19.942990: [debug] Completing package location information from chiasma-0.1.0.0@sha256:0d95d24746716430eca2d54755384e7f0da8c6cac4f4171705f47ff7c907ba87,2472
2019-08-18 14:57:19.943932: [debug] Completing package location information from posix-pty-0.
@isovector
isovector / code.gs
Created July 7, 2019 17:44 — forked from zhenyanghua/code.gs
Googlemaps + Google Sheets + Google Forms
var SPREADSHEET_ID='Google Sheets ID';
var SHEET_NAME = 'Google Sheets Table Name';
function doGet(request) {
var callback = request.parameters.jsonp;
var range = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName(SHEET_NAME).getDataRange();
var json = callback+'('+Utilities.jsonStringify(range.getValues())+')';
return ContentService.createTextOutput(json).setMimeType(ContentService.MimeType.JAVASCRIPT);
}