Skip to content

Instantly share code, notes, and snippets.

-- While building custom Setup.hs for package clash-prelude-0.99 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.0.0.2_ghc-8.2.1.exe --builddir=.stack-work\dist\e53504d9 build lib:clash-prelude --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: D:\code\clash-compiler\.stack-work\logs\clash-prelude-0.99.log
Configuring clash-prelude-0.99...
Warning:
This package indirectly depends on multiple versions of the same package. This is very likely to cause a compile failure.
package time (time-1.8.0.2-6D7zA6hvj7J2L4fRhEphEi) requires Win32-2.4.0.0-6h2GtvaqnjAGgAinwN44RU
package time (time-1.8.0.2) requires Win32-2.5.4.1
cabal.exe: Error parsing project file
D:\code\clash-compiler\cabal.project:6:
Parse of field 'allow-newer' failed.
@cemerick
cemerick / Shift.hs
Last active February 22, 2018 19:55
module Core.Shift where
import CLaSH.Prelude
import CLaSH.Signal
import CLaSH.Sized.BitVector
import Data.Word
import Data.Bits
type Word256 = BitVector 256
@cemerick
cemerick / Foo.hs
Last active February 16, 2018 22:06
-- tweaking `CLaSH.Sized.Vector.vfold` so that an initial vector can be provided/built upon
-- reusing the `Append` motive from the main `dfold` example
data Append (m :: Nat) (a :: *) (f :: TyFun Nat *) :: *
type instance Apply (Append m a) l = Vec (l + m) a
vifold :: forall k j a b . (KnownNat k, KnownNat j)
=> (forall l . SNat l -> a -> Vec (j + l) b -> Vec (j + l + 1) b)
-> Vec j b
-- in `cabal exec clash -- --interactive`
CLaSH.Prelude> import Data.Int
CLaSH.Prelude Data.Int> let x = 56 :: Int8
CLaSH.Prelude Data.Int> x + x
112
-- in `Foo.hs`:
module Foo where
(def words (set (.split (slurp "g:/words") "\n")))
=> #'user/words
(count words)
=> 99171
(require '[clojure.math.combinatorics :refer (permutations)])
=> nil
(count (permutations "plates"))
=> 720
(first (permutations "plates"))
=> (\p \l \a \t \e \s)
#!/usr/bin/bash
filename="$1"
wait="🕜"
# test 🕜🕜🕜🕜pausing
function keystroke-delay {
delay=`bc <<END
scale=2
@cemerick
cemerick / an-preview.png
Last active June 27, 2017 21:12
"Ancap News" greasemonkey script; go to https://github.com/cemerick/ancap-news
an-preview.png
@cemerick
cemerick / gist:00e9e8d1da6461d9daaddd0232943411
Created June 5, 2017 15:11
optional alternative :filespec destination path
; e.g. usage
:filespecs [{:type :path :path "source/directory" :root "destination/directory/"}]
; at the end of project.clj
(require 'leiningen.jar)
(in-ns 'leiningen.jar)
(defmethod copy-to-jar :path [project jar-os acc spec]
(let [root-file (io/file (:path spec))
@cemerick
cemerick / user.clj
Last active April 27, 2017 13:39
reduce-for: easier-to-understand nested reductions
; a toy example of a nested reduction; especially when function bodies are nontrivial, or when the nesting
; gets much deeper than 2 levels, it's easy to lose track of which values are being reduced over at each
; level, etc
(let [x {:a [1 2 3] :b [4 5 6]}]
(reduce
(fn [x [k vs]]
(reduce
(fn [x v] (update x :sum (fnil + 0) v))
x