Skip to content

Instantly share code, notes, and snippets.

-- formulate in standard style, as a mental crutch
tryUntilSuccess :: [a -> Either e b] -> a -> Either [e] b
tryUntilSuccess fs x = let ys = map ($ x) fs
in case dropWhile isLeft ys of
[] -> Left $ lefts $ takeWhile isLeft ys
(Right y):_ -> Right y
-- Formulate in simply polymorphic CPS next
-- This is the signature of the... thing... I'm trying to write
tryUntilSuccessCPS :: [a -> (Either f b -> c) -> c] -> ((a -> (Either [f] b -> e) -> e) -> d) -> d
@Solonarv
Solonarv / A.hs
Created February 4, 2016 01:15
Sample GHC Core output when dealing with multiple classes
module A where
class Foo a where foo :: a -> String
instance Show a => Foo [a] where foo = ($ "") . showList
@Solonarv
Solonarv / Show-transformed.hs
Created February 5, 2016 17:51
Transformation exposing typeclass dictionaries
data FooDict a = FooDict {
foo :: a -> Int
bar :: a -> [()]
}
/h/constraint-witness/plugin (master)
$ ghc ConstraintWitness.Test
[5 of 5] Compiling ConstraintWitness.Test ( ConstraintWitness\Test.hs, ConstraintWitness\Test.o )
ConstraintWitness\Test.hs:15:9:
Couldn't match type `(:~:) a' with `Int :~: a'
Expected type: Witness (Int ~ a) -> Int :~: a
Actual type: Int :~: a -> Int :~: a
Relevant bindings include
test1 :: Witness (Int ~ a) -> Int :~: a

Setting: Eberon

General setting

Humanity in strange state

  • besieged
  • in the past: humanity had to build an underground city, Sharraat, to protect itself from the Enemy.
  • Humanity is expanding again
  • dark mood
  • tech/culture level: 16th-17th ctry
  • Magic is common, but not commonplace
; Path of Exile macros
; go to hideout
$^h:: Send {Enter}/hideout{Enter}
; logout
$^l:: Send {Enter}/exit{Enter}
; attack-in-place
Capslock:: Send {LShift Down}
; Path of Exile macros
; go to hideout
#IfWinActive, Path of Exile
^h:: Send {Enter}+{Home}^c/hideout{Enter}{Enter}^v{Escape}
; logout
#IfWinActive, Path of Exile
$^l:: Send {Enter}+{Home}^c/exit{Enter}{Enter}^v{Escape}
#-*-coding:utf8;-*-
#qpy:3
#qpy:console
from random import randint
def bin(n, width):
return blockify(("{:0"+str(width)+"b}").format(n))
def blockify(s):
"Talents"
{
"10"
{
"left" "talent_1"
"right" "talent_2"
}
"15"
{
"left" "talent_3"
flicker_rapid_strike = class({})
LinkLuaModifier("modifier_rapid_strike", "heroes/hero_flicker/modifier_rapid_strike.lua", LUA_MODIFIER_MOTION_NONE)
function flicker_rapid_strike:OnSpellStart()
local target = self:GetCursorTarget()
self:GetCaster().rapid_strike_target = target
self:GetCaster():AddNewModifier(self:GetCaster(), self, "modifier_rapid_strike", {})
end