diff options
| author | Miguel <m.i@gmx.at> | 2019-03-17 18:14:32 +0100 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2019-03-17 18:14:32 +0100 |
| commit | 0e4810dcfb132bf276a282e25b8523a4009ae08b (patch) | |
| tree | dac6dce820f0a35d9ed7ea7676982a0f86fd0edb /080_blog/00040_Haskell | |
| parent | ad6411e9ec256b03f20b9195e25cb128fe02c628 (diff) | |
rename blog dir
Diffstat (limited to '080_blog/00040_Haskell')
24 files changed, 0 insertions, 1617 deletions
diff --git a/080_blog/00040_Haskell/00010_Links-and-Literature/index.md b/080_blog/00040_Haskell/00010_Links-and-Literature/index.md deleted file mode 100644 index 999c574..0000000 --- a/080_blog/00040_Haskell/00010_Links-and-Literature/index.md +++ /dev/null @@ -1,17 +0,0 @@ -# Haskell - Books, Links and Papers - -A growing collection of external links and books concerning Haskell. - -* **Learn You a Haskell** for Great Good by Marian Lipovaca -* **Real World Haskell** by Bryan O'Sullivan, Don Stewart, and John Goerzen -* **Parallel and Concurrent Programming in Haskell** by Simon Marlow -* **Haskell Wiki** <https://wiki.haskell.org> -* **UPENN CIS 194** <https://www.seas.upenn.edu/~cis194/spring13/> -* **What I Wish I Knew When Learning Haskell** by Stephen Diehl <http://dev.stephendiehl.com/hask/> -* **Data61 Course** <https://github.com/data61/fp-course> -* **Monads for functional programming (paper)** by Philip Wadler -* **Functional Pearl (paper)** -* **Why Functional Programming Matters (paper)** -* **Mailing Lists** <https://www.haskell.org/mailing-lists/> -* **IRC** #haskell at chat.freenode.at -* **Monadic Warsaw** diff --git a/080_blog/00040_Haskell/00020_GHC-Notes/index.md b/080_blog/00040_Haskell/00020_GHC-Notes/index.md deleted file mode 100644 index c945319..0000000 --- a/080_blog/00040_Haskell/00020_GHC-Notes/index.md +++ /dev/null @@ -1,39 +0,0 @@ -# The Glasgow Haskell Compiler - -## Some GHC Flags - - -v verbose mode - -O2 level 2 optimizations - -rtsopts allow +RTS flags - -prof enable basic time and allocation profiling - -auto-all cost centers on all top level functions - (you can also add them via the SCC pragma) - -caf-all generate data for CAFs (constant applicative forms) - -fforce-recomp force recompilation - -threaded Use threaed runtime - -eventlog enables +RTS -l flag - - -Wall - -Werror - - Notes: you will obtain the profiling versions of dependancies via: - stack install --profile [libraryname] - - -fprof-auto replaced -auto-all - -fprof-cafs replaced -caf-all - -## Some +RTS flags - - -K set stack limit - -s statistic reporting - -p profiling - -hc extract heap profile - -hy allocation by type - -hd allocation by constructor - -ix x is sampling frequency in seconds. e.g. 0.01) - -Nx x is number of cores to utilize - -l emit log file (can be used threadscope) - -ddump-simpl generate core - - Note: render the heap profile as graph with: hp2ps -e8in -c file.hp - show eventlog with: threadscope file.eventlog diff --git a/080_blog/00040_Haskell/00030_Xmonad-contribution/index.md b/080_blog/00040_Haskell/00030_Xmonad-contribution/index.md deleted file mode 100644 index 1a5bf0f..0000000 --- a/080_blog/00040_Haskell/00030_Xmonad-contribution/index.md +++ /dev/null @@ -1,20 +0,0 @@ - April 2018 -# Pretty printer for empty visible workspaces - -My little contribution to **xmonad-contrib**, adding functionality to the -marvelous xmonad tiling window manager, I love and use since a couple of -years. - -## Description - -Simple extensions of the pretty printer to differentiate between empty and non-empty visible workspaces. Analogical to the existing functionality for hidden workspaces. Particularly useful if some displays managed by xmonad are turned off temporarily. - -The new 'ppVisibleNoWindows' function was wrapped in a Maybe data type. Its value dafaults to 'Nothing' and 'ppVisible' is used as fallback. - -## Motivation - -My TV is often turned off. Still I want to know if its workspace contains any windows, without having to switch workspaces. - -## Github Link -| _Xmonad-Contrib: Added pretty printer for empty visible workspaces (wrapped in Maybe)_ -| <https://github.com/xmonad/xmonad-contrib/pull/241> diff --git a/080_blog/00040_Haskell/00040_Graham-Scan/index.md b/080_blog/00040_Haskell/00040_Graham-Scan/index.md deleted file mode 100644 index 195dbe1..0000000 --- a/080_blog/00040_Haskell/00040_Graham-Scan/index.md +++ /dev/null @@ -1,128 +0,0 @@ -Haskell – Convex Hull – Graham Scan -=================================== - -December 16, 2017 - -Playing with Convex Hulls (via Graham Scan) and SVG Export in Haskell: - -This is an embedded SVG generated by the Haskell programm below: - -<svg style="background-color:black;border:3px solid green;margin:2px;" width="330" height="330"><circle cx="250.04284841107818" cy="201.75346959836142" r="5" fill="rgb(30,150,112)"></circle> <circle cx="168.06592772450588" cy="111.843758303498" r="5" fill="rgb(30,150,47)"></circle> <circle cx="189.1691117845287" cy="250.13932743386943" r="5" fill="rgb(30,150,107)"></circle> <circle cx="130.9047490592456" cy="253.98605115515113" r="5" fill="rgb(30,150,108)"></circle> <circle cx="133.43531697969132" cy="255.82160214659208" r="5" fill="rgb(30,150,109)"></circle> <circle cx="182.304020607504" cy="105.5457583516454" r="5" fill="rgb(30,150,60)"></circle> <circle cx="251.5850563588106" cy="65.40572671380644" r="5" fill="rgb(30,150,139)"></circle> <circle cx="171.80987991027797" cy="186.35194010383304" r="5" fill="rgb(30,150,37)"></circle> <circle cx="207.80255687618114" cy="132.29096928312123" r="5" fill="rgb(30,150,61)"></circle> <circle cx="195.49409554478555" cy="83.18625335312012" r="5" fill="rgb(30,150,87)"></circle> <circle cx="92.72787404887227" cy="119.1126315578156" r="5" fill="rgb(30,150,76)"></circle> <circle cx="132.01826662198954" cy="259.3032349925243" r="5" fill="rgb(30,150,113)"></circle> <circle cx="254.30961953454" cy="228.57029782885428" r="5" fill="rgb(30,150,131)"></circle> <circle cx="119.4923496517701" cy="224.99714968272923" r="5" fill="rgb(30,150,83)"></circle> <circle cx="104.9029796235115" cy="248.66327951701538" r="5" fill="rgb(30,150,112)"></circle> <circle cx="177.91310266020778" cy="126.62370162491455" r="5" fill="rgb(30,150,38)"></circle> <circle cx="266.34722960770284" cy="187.10030895652505" r="5" fill="rgb(30,150,123)"></circle> <circle cx="198.64979304554535" cy="188.53978156044514" r="5" fill="rgb(30,150,58)"></circle> <circle cx="153.9541873486683" cy="57.38878027501561" r="5" fill="rgb(30,150,103)"></circle> <circle cx="170.63539358861877" cy="176.00651132793615" r="5" fill="rgb(30,150,27)"></circle> <circle cx="28.36356558991553" cy="95.4663889254756" r="5" fill="rgb(30,150,148)"></circle> <circle cx="144.84264545840333" cy="98.7746298856041" r="5" fill="rgb(30,150,60)"></circle> <circle cx="190.22210041855752" cy="135.09803947887505" r="5" fill="rgb(30,150,42)"></circle> <circle cx="182.77513675509647" cy="226.9525049033775" r="5" fill="rgb(30,150,81)"></circle> <circle cx="91.5545715639725" cy="181.77301165017755" r="5" fill="rgb(30,150,73)"></circle> <circle cx="260.52976404909987" cy="126.7650903973776" r="5" fill="rgb(30,150,116)"></circle> <circle cx="199.24706728106065" cy="85.8145677264196" r="5" fill="rgb(30,150,87)"></circle> <circle cx="140.1028394863066" cy="228.94903207761297" r="5" fill="rgb(30,150,80)"></circle> <circle cx="86.45512221013155" cy="142.21354112994936" r="5" fill="rgb(30,150,74)"></circle> <circle cx="104.7684570753781" cy="95.55777241192189" r="5" fill="rgb(30,150,82)"></circle> <circle cx="109.8116912935771" cy="201.82250066393837" r="5" fill="rgb(30,150,69)"></circle> <circle cx="226.2427629753817" cy="260.4928511647599" r="5" fill="rgb(30,150,135)"></circle> <circle cx="207.52854584882476" cy="98.23832427848856" r="5" fill="rgb(30,150,82)"></circle> <circle cx="137.34727138289463" cy="248.54598831387364" r="5" fill="rgb(30,150,101)"></circle> <circle cx="67.6437518548912" cy="235.9987917257608" r="5" fill="rgb(30,150,126)"></circle> <circle cx="146.63935287123562" cy="199.14394352970618" r="5" fill="rgb(30,150,47)"></circle> <circle cx="166.09256427911302" cy="242.83302095042907" r="5" fill="rgb(30,150,94)"></circle> <circle cx="184.35531117256224" cy="161.9097796435418" r="5" fill="rgb(30,150,32)"></circle> <circle cx="135.0509917491549" cy="104.7711158701602" r="5" fill="rgb(30,150,57)"></circle> <circle cx="219.20921008912157" cy="115.18635102633722" r="5" fill="rgb(30,150,80)"></circle> <circle cx="163.3590840337916" cy="68.94091343798308" r="5" fill="rgb(30,150,91)"></circle> <circle cx="106.80531573718335" cy="199.21285711361014" r="5" fill="rgb(30,150,69)"></circle> <circle cx="91.69394054319545" cy="249.00283065566003" r="5" fill="rgb(30,150,120)"></circle> <circle cx="42.69884845673566" cy="208.11969850342197" r="5" fill="rgb(30,150,131)"></circle> <circle cx="150.6236743485051" cy="188.8620474963915" r="5" fill="rgb(30,150,36)"></circle> <circle cx="158.90382633613356" cy="274.07594874616575" r="5" fill="rgb(30,150,126)"></circle> <circle cx="203.43810936607744" cy="240.5130006472947" r="5" fill="rgb(30,150,104)"></circle> <circle cx="90.52909317079552" cy="217.88023089739372" r="5" fill="rgb(30,150,95)"></circle> <circle cx="142.0940864941062" cy="129.52923503909" r="5" fill="rgb(30,150,30)"></circle> <circle cx="183.3037554100898" cy="163.4224683254946" r="5" fill="rgb(30,150,31)"></circle> <circle cx="254.59761377280722" cy="194.8355635900217" r="5" fill="rgb(30,150,113)"></circle> <circle cx="70.01341642229187" cy="145.07162677904222" r="5" fill="rgb(30,150,90)"></circle> <circle cx="245.95274031933198" cy="105.6150023686217" r="5" fill="rgb(30,150,109)"></circle> <circle cx="179.3874489883276" cy="161.3271491454406" r="5" fill="rgb(30,150,26)"></circle> <circle cx="174.8322909478738" cy="98.24413130742855" r="5" fill="rgb(30,150,63)"></circle> <circle cx="76.57661314940059" cy="232.5620695235213" r="5" fill="rgb(30,150,117)"></circle> <circle cx="110.20050744456465" cy="131.53437983901722" r="5" fill="rgb(30,150,53)"></circle> <circle cx="101.02068320616426" cy="147.86628733061426" r="5" fill="rgb(30,150,57)"></circle> <circle cx="165.8572064460344" cy="278.14694842092365" r="5" fill="rgb(30,150,131)"></circle> <circle cx="100.51994290684408" cy="135.00585528086626" r="5" fill="rgb(30,150,61)"></circle> <circle cx="93.82764097353034" cy="129.06320594160917" r="5" fill="rgb(30,150,70)"></circle> <circle cx="253.87187416210415" cy="154.5167254215345" r="5" fill="rgb(30,150,105)"></circle> <circle cx="139.60104049751217" cy="105.10237893042421" r="5" fill="rgb(30,150,55)"></circle> <circle cx="217.63333767494922" cy="82.01911898999408" r="5" fill="rgb(30,150,102)"></circle> <circle cx="155.07651713848244" cy="202.01229698806958" r="5" fill="rgb(30,150,49)"></circle> <circle cx="38.84571396023169" cy="211.71370049299298" r="5" fill="rgb(30,150,137)"></circle> <circle cx="131.35457460373755" cy="229.43649756282707" r="5" fill="rgb(30,150,82)"></circle> <circle cx="101.8811149603446" cy="60.806865650812135" r="5" fill="rgb(30,150,114)"></circle> <circle cx="108.91357375361146" cy="183.38328826229434" r="5" fill="rgb(30,150,57)"></circle> <circle cx="98.29711330271346" cy="109.47482179229984" r="5" fill="rgb(30,150,77)"></circle> <circle cx="172.28688779196867" cy="181.46233752550535" r="5" fill="rgb(30,150,33)"></circle> <circle cx="93.77188129034651" cy="152.09728921642983" r="5" fill="rgb(30,150,65)"></circle> <circle cx="39.16221208499168" cy="220.08715706943792" r="5" fill="rgb(30,150,141)"></circle> <circle cx="82.90283027529738" cy="187.23987823799342" r="5" fill="rgb(30,150,83)"></circle> <circle cx="36.83140136457256" cy="237.10836498299798" r="5" fill="rgb(30,150,152)"></circle> <circle cx="159.04913429058357" cy="193.6137496983329" r="5" fill="rgb(30,150,41)"></circle> <circle cx="149.8458394746179" cy="243.69722670699878" r="5" fill="rgb(30,150,94)"></circle> <circle cx="139.0710264338086" cy="147.9219518871481" r="5" fill="rgb(30,150,18)"></circle> <circle cx="156.87676351678834" cy="196.31621769543472" r="5" fill="rgb(30,150,43)"></circle> <circle cx="76.22813867551673" cy="58.065254250002404" r="5" fill="rgb(30,150,132)"></circle> <circle cx="114.74404579519961" cy="250.4087840946835" r="5" fill="rgb(30,150,110)"></circle> <circle cx="87.15900106326063" cy="148.70527298969148" r="5" fill="rgb(30,150,72)"></circle> <circle cx="26.847893428897535" cy="218.50461482065617" r="5" fill="rgb(30,150,151)"></circle> <circle cx="167.86224317149043" cy="217.21693364547622" r="5" fill="rgb(30,150,67)"></circle> <circle cx="282.75471021838604" cy="222.40422121056434" r="5" fill="rgb(30,150,153)"></circle> <circle cx="113.65929983185622" cy="172.1380647926459" r="5" fill="rgb(30,150,47)"></circle> <circle cx="145.09413645816042" cy="155.25057732001034" r="5" fill="rgb(30,150,10)"></circle> <circle cx="237.53341559112823" cy="129.6627629148239" r="5" fill="rgb(30,150,91)"></circle> <circle cx="204.79599735549814" cy="127.38370156552024" r="5" fill="rgb(30,150,60)"></circle> <circle cx="67.74775493976351" cy="139.97850753416574" r="5" fill="rgb(30,150,94)"></circle> <circle cx="210.31226434244496" cy="247.09502723685614" r="5" fill="rgb(30,150,114)"></circle> <circle cx="138.5101000851674" cy="278.7105427190394" r="5" fill="rgb(30,150,132)"></circle> <circle cx="169.19801602950238" cy="114.05245580753565" r="5" fill="rgb(30,150,46)"></circle> <circle cx="248.30023598811576" cy="139.82948336104496" r="5" fill="rgb(30,150,100)"></circle> <circle cx="84.30932668117279" cy="219.93833030785126" r="5" fill="rgb(30,150,101)"></circle> <circle cx="132.24331417077946" cy="291.2609993001805" r="5" fill="rgb(30,150,146)"></circle> <circle cx="160.94658587409114" cy="77.98657154244181" r="5" fill="rgb(30,150,82)"></circle> <circle cx="189.89599533144758" cy="214.5141658021252" r="5" fill="rgb(30,150,73)"></circle> <circle cx="274.07238032907736" cy="114.61040292334776" r="5" fill="rgb(30,150,133)"></circle> <circle cx="173.4334175877005" cy="142.41875279561097" r="5" fill="rgb(30,150,23)"></circle> <circle cx="81.59666952240286" cy="157.09683628233245" r="5" fill="rgb(30,150,78)"></circle> <circle cx="113.74263460749069" cy="245.6984634962466" r="5" fill="rgb(30,150,105)"></circle> <circle cx="128.62844736870682" cy="89.1045872570648" r="5" fill="rgb(30,150,75)"></circle> <circle cx="117.09080103183433" cy="256.3606817576775" r="5" fill="rgb(30,150,114)"></circle> <circle cx="107.0510464556047" cy="63.6364881544602" r="5" fill="rgb(30,150,109)"></circle> <circle cx="146.06063748335822" cy="155.5476601817892" r="5" fill="rgb(30,150,9)"></circle> <circle cx="19.797156728201166" cy="208.00327375672293" r="5" fill="rgb(30,150,154)"></circle> <circle cx="224.6871261564196" cy="59.32941538253692" r="5" fill="rgb(30,150,125)"></circle> <circle cx="18.330634507062157" cy="169.68512490920642" r="5" fill="rgb(30,150,146)"></circle> <circle cx="117.71877593737015" cy="157.71566996945785" r="5" fill="rgb(30,150,39)"></circle> <circle cx="150.90744004872494" cy="125.69996651911103" r="5" fill="rgb(30,150,31)"></circle> <circle cx="172.0555296451493" cy="147.95967101995438" r="5" fill="rgb(30,150,19)"></circle> <circle cx="211.71510600782037" cy="168.6836805807738" r="5" fill="rgb(30,150,61)"></circle> <circle cx="60.24756518573737" cy="246.71025625213787" r="5" fill="rgb(30,150,140)"></circle> <circle cx="103.23366497661333" cy="219.01237316076927" r="5" fill="rgb(30,150,87)"></circle> <circle cx="273.7017283881007" cy="172.2120764305319" r="5" fill="rgb(30,150,127)"></circle> <circle cx="97.80303649638779" cy="204.85716575700624" r="5" fill="rgb(30,150,80)"></circle> <circle cx="221.46148887605563" cy="164.77249284618293" r="5" fill="rgb(30,150,71)"></circle> <circle cx="50.524491137739275" cy="89.6937642622213" r="5" fill="rgb(30,150,130)"></circle> <circle cx="204.0380699117014" cy="37.35498291700646" r="5" fill="rgb(30,150,135)"></circle> <circle cx="143.40838746301495" cy="259.3899906185589" r="5" fill="rgb(30,150,111)"></circle> <circle cx="266.77265013944714" cy="123.56187324575204" r="5" fill="rgb(30,150,123)"></circle> <circle cx="121.09007007148857" cy="87.19247610877495" r="5" fill="rgb(30,150,80)"></circle> <circle cx="80.22930186274945" cy="70.1701303865456" r="5" fill="rgb(30,150,120)"></circle> <circle cx="180.45553719901778" cy="175.95293706048568" r="5" fill="rgb(30,150,35)"></circle> <circle cx="222.7506070445607" cy="80.61735797855984" r="5" fill="rgb(30,150,106)"></circle> <circle cx="158.2801305209321" cy="168.2844490594726" r="5" fill="rgb(30,150,14)"></circle> <circle cx="209.07427850176043" cy="146.00598552038022" r="5" fill="rgb(30,150,58)"></circle> <circle cx="181.8649175345449" cy="96.87537796898624" r="5" fill="rgb(30,150,68)"></circle> <circle cx="57.818033309206335" cy="94.70613646665379" r="5" fill="rgb(30,150,121)"></circle> <circle cx="120.75849455577627" cy="136.86343872502906" r="5" fill="rgb(30,150,41)"></circle> <circle cx="238.4042177525126" cy="214.12837089906836" r="5" fill="rgb(30,150,108)"></circle> <circle cx="134.82175169469224" cy="282.8625044224542" r="5" fill="rgb(30,150,137)"></circle> <circle cx="124.37897828966902" cy="141.19895073915285" r="5" fill="rgb(30,150,35)"></circle> <circle cx="71.30829640124736" cy="228.6244751809119" r="5" fill="rgb(30,150,118)"></circle> <circle cx="202.8966932024821" cy="175.5553271682116" r="5" fill="rgb(30,150,55)"></circle> <circle cx="112.28137080688083" cy="198.61669563281163" r="5" fill="rgb(30,150,64)"></circle> <circle cx="230.79728693422757" cy="72.90445718027976" r="5" fill="rgb(30,150,118)"></circle> <circle cx="158.79949910260785" cy="182.82233984968175" r="5" fill="rgb(30,150,29)"></circle> <circle cx="58.56877652829822" cy="147.81482668362486" r="5" fill="rgb(30,150,102)"></circle> <circle cx="188.43313680897649" cy="169.0946893542551" r="5" fill="rgb(30,150,38)"></circle> <circle cx="183.18362562517675" cy="146.11507672367435" r="5" fill="rgb(30,150,31)"></circle> <circle cx="256.71894488922624" cy="172.26799561066733" r="5" fill="rgb(30,150,109)"></circle> <circle cx="245.03698870042268" cy="103.65831068003733" r="5" fill="rgb(30,150,110)"></circle> <circle cx="50.70099080152846" cy="87.39565736040664" r="5" fill="rgb(30,150,132)"></circle> <circle cx="130.64433518067872" cy="28.1630727673696" r="5" fill="rgb(30,150,137)"></circle> <circle cx="94.56724747823085" cy="150.4574267806313" r="5" fill="rgb(30,150,64)"></circle> <circle cx="67.04524904809107" cy="53.02953597638252" r="5" fill="rgb(30,150,143)"></circle> <circle cx="78.62648151898244" cy="81.82623533931174" r="5" fill="rgb(30,150,112)"></circle> <circle cx="161.15153490662175" cy="96.99587052613042" r="5" fill="rgb(30,150,61)"></circle> <circle cx="245.67175110458567" cy="217.1949486286303" r="5" fill="rgb(30,150,116)"></circle> <circle cx="157.1543105644771" cy="197.82600606935443" r="5" fill="rgb(30,150,45)"></circle> <circle cx="277.47686405127035" cy="159.7874794173272" r="5" fill="rgb(30,150,130)"></circle> <circle cx="233.345787687867" cy="166.3550830285023" r="5" fill="rgb(30,150,84)"></circle> <circle cx="117.83415920099087" cy="164.15103726228338" r="5" fill="rgb(30,150,40)"></circle> <circle cx="120.13909214312396" cy="172.46043638719644" r="5" fill="rgb(30,150,41)"></circle> <circle cx="205.5110421762653" cy="72.98191491764617" r="5" fill="rgb(30,150,102)"></circle> <circle cx="96.80163765991092" cy="62.92764545891779" r="5" fill="rgb(30,150,115)"></circle> <circle cx="124.88959943706861" cy="225.15044973370053" r="5" fill="rgb(30,150,81)"></circle> <circle cx="164.15746228129717" cy="208.86982033897232" r="5" fill="rgb(30,150,58)"></circle> <circle cx="61.99262838338286" cy="146.89828049656404" r="5" fill="rgb(30,150,99)"></circle> <circle cx="172.85767813829926" cy="78.87359339217413" r="5" fill="rgb(30,150,83)"></circle> <circle cx="253.24460591758893" cy="78.41050145160236" r="5" fill="rgb(30,150,132)"></circle> <circle cx="118.82587572803565" cy="135.954087178179" r="5" fill="rgb(30,150,43)"></circle> <circle cx="98.37373962332532" cy="154.76680314997353" r="5" fill="rgb(30,150,60)"></circle> <circle cx="122.31937398668295" cy="165.877836976854" r="5" fill="rgb(30,150,36)"></circle> <circle cx="149.9286260021866" cy="46.27747926759328" r="5" fill="rgb(30,150,115)"></circle> <circle cx="150.6188359447945" cy="196.58148153111807" r="5" fill="rgb(30,150,44)"></circle> <circle cx="96.17812624734673" cy="29.840537240648665" r="5" fill="rgb(30,150,146)"></circle> <circle cx="128.59108692837646" cy="194.72588208165476" r="5" fill="rgb(30,150,50)"></circle> <circle cx="38.82122769921369" cy="75.5662312500352" r="5" fill="rgb(30,150,149)"></circle> <circle cx="79.94903569579193" cy="186.85152375858772" r="5" fill="rgb(30,150,86)"></circle> <circle cx="204.77448960563186" cy="203.64418479165812" r="5" fill="rgb(30,150,73)"></circle> <circle cx="102.88584275265274" cy="197.78063641998918" r="5" fill="rgb(30,150,71)"></circle> <circle cx="159.65478381235536" cy="151.46210092241446" r="5" fill="rgb(30,150,6)"></circle> <circle cx="134.10239921221842" cy="161.49132008992956" r="5" fill="rgb(30,150,23)"></circle> <circle cx="139.09958643074796" cy="219.08371036054947" r="5" fill="rgb(30,150,70)"></circle> <circle cx="146.567509740401" cy="147.39910865707066" r="5" fill="rgb(30,150,12)"></circle> <circle cx="131.83426320463218" cy="162.48898240420658" r="5" fill="rgb(30,150,25)"></circle> <circle cx="173.79168328304365" cy="42.17798379123914" r="5" fill="rgb(30,150,121)"></circle> <circle cx="109.95961714856101" cy="176.03754103367197" r="5" fill="rgb(30,150,52)"></circle> <circle cx="193.05669580827944" cy="188.37810635692216" r="5" fill="rgb(30,150,53)"></circle> <circle cx="104.13084921683644" cy="251.78865585330408" r="5" fill="rgb(30,150,116)"></circle> <circle cx="151.87833723048243" cy="141.41758941633188" r="5" fill="rgb(30,150,14)"></circle> <circle cx="170.37984822769394" cy="82.74727274516178" r="5" fill="rgb(30,150,78)"></circle> <circle cx="269.0943849070194" cy="126.07704256534687" r="5" fill="rgb(30,150,125)"></circle> <circle cx="125.65122538235366" cy="91.64498546299714" r="5" fill="rgb(30,150,74)"></circle> <circle cx="197.53172426918525" cy="128.69408459081865" r="5" fill="rgb(30,150,53)"></circle> <circle cx="174.6642667835747" cy="158.9818125733492" r="5" fill="rgb(30,150,21)"></circle> <circle cx="24.442195159380894" cy="149.95618131450235" r="5" fill="rgb(30,150,138)"></circle> <circle cx="230.57251917564554" cy="160.3740796367529" r="5" fill="rgb(30,150,80)"></circle> <circle cx="116.98152224764455" cy="119.15376321927269" r="5" fill="rgb(30,150,55)"></circle> <circle cx="76.56308571870836" cy="116.27351644357717" r="5" fill="rgb(30,150,92)"></circle> <circle cx="114.18131147378502" cy="228.83119145309104" r="5" fill="rgb(30,150,89)"></circle> <circle cx="61.43526198061147" cy="189.2999144311051" r="5" fill="rgb(30,150,105)"></circle> <circle cx="47.159274262692136" cy="232.7974361297379" r="5" fill="rgb(30,150,141)"></circle> <circle cx="182.3516235175878" cy="147.2513501676052" r="5" fill="rgb(30,150,30)"></circle> <circle cx="212.65566528240188" cy="106.8365872143227" r="5" fill="rgb(30,150,79)"></circle> <circle cx="103.57241974005441" cy="244.94215489038754" r="5" fill="rgb(30,150,110)"></circle> <circle cx="118.74222089776532" cy="72.89123743199185" r="5" fill="rgb(30,150,95)"></circle> <circle cx="249.90029463264338" cy="210.31306906279752" r="5" fill="rgb(30,150,116)"></circle> <circle cx="138.08211482254237" cy="201.93298825621986" r="5" fill="rgb(30,150,53)"></circle> <circle cx="99.45732504409123" cy="125.68120399343496" r="5" fill="rgb(30,150,66)"></circle> <circle cx="95.25417908245312" cy="199.8722971385956" r="5" fill="rgb(30,150,79)"></circle> <circle cx="173.5225523778074" cy="183.25325411366197" r="5" fill="rgb(30,150,35)"></circle> <circle cx="161.10556608174647" cy="287.6615940190875" r="5" fill="rgb(30,150,141)"></circle> <circle cx="99.12828988863924" cy="192.5533080036565" r="5" fill="rgb(30,150,71)"></circle> <circle cx="138.3352868758438" cy="198.47497165114282" r="5" fill="rgb(30,150,49)"></circle> <circle cx="193.78642259086737" cy="131.00758347474238" r="5" fill="rgb(30,150,48)"></circle> <circle cx="232.588767217581" cy="166.3351798078713" r="5" fill="rgb(30,150,83)"></circle> <circle cx="39.31251655429242" cy="177.08833200695184" r="5" fill="rgb(30,150,125)"></circle> <circle cx="185.95704286695798" cy="177.33472005753862" r="5" fill="rgb(30,150,40)"></circle> <circle cx="147.90048340005285" cy="71.10204540244274" r="5" fill="rgb(30,150,89)"></circle> <circle cx="166.8845546562491" cy="172.74666158680589" r="5" fill="rgb(30,150,22)"></circle> <circle cx="277.6246746037615" cy="90.30367358125177" r="5" fill="rgb(30,150,147)"></circle> <circle cx="163.7772455221003" cy="119.59515393163443" r="5" fill="rgb(30,150,38)"></circle> <circle cx="100.8084390756384" cy="179.4519113235002" r="5" fill="rgb(30,150,63)"></circle> <circle cx="232.797670719027" cy="208.95839448193917" r="5" fill="rgb(30,150,100)"></circle> <circle cx="116.20169369192108" cy="215.30258202242675" r="5" fill="rgb(30,150,76)"></circle> <circle cx="129.14679183749018" cy="162.7114418319233" r="5" fill="rgb(30,150,28)"></circle> <circle cx="172.21836963279975" cy="53.36276325209766" r="5" fill="rgb(30,150,109)"></circle> <circle cx="122.18074560789485" cy="31.35034324083615" r="5" fill="rgb(30,150,135)"></circle> <circle cx="234.92525075624567" cy="197.12521379760366" r="5" fill="rgb(30,150,95)"></circle> <circle cx="287.55861698920245" cy="191.54124064684203" r="5" fill="rgb(30,150,146)"></circle> <circle cx="208.95996913096113" cy="86.31885888350531" r="5" fill="rgb(30,150,92)"></circle> <circle cx="117.94515643676408" cy="125.74735207871876" r="5" fill="rgb(30,150,50)"></circle> <circle cx="97.65527429491222" cy="84.40941345270775" r="5" fill="rgb(30,150,96)"></circle> <circle cx="148.98989317857215" cy="107.68365082202222" r="5" fill="rgb(30,150,50)"></circle> <circle cx="83.80736835288073" cy="136.33946071934116" r="5" fill="rgb(30,150,78)"></circle> <circle cx="199.93779378476336" cy="138.9591143291108" r="5" fill="rgb(30,150,50)"></circle> <circle cx="158.33576748574276" cy="205.38810908810458" r="5" fill="rgb(30,150,53)"></circle> <circle cx="157.50068512278443" cy="189.02964217352948" r="5" fill="rgb(30,150,36)"></circle> <circle cx="153.9943950342934" cy="149.63839051508984" r="5" fill="rgb(30,150,5)"></circle> <circle cx="227.12941615549062" cy="152.9883523085731" r="5" fill="rgb(30,150,76)"></circle> <circle cx="206.6719685811751" cy="116.71508779989065" r="5" fill="rgb(30,150,68)"></circle> <circle cx="148.85052880252837" cy="109.67806598750374" r="5" fill="rgb(30,150,48)"></circle> <circle cx="226.66377000731163" cy="61.32427435125567" r="5" fill="rgb(30,150,125)"></circle> <circle cx="66.10772769569768" cy="110.10357863882781" r="5" fill="rgb(30,150,105)"></circle> <circle cx="152.27636978490196" cy="114.5539300162203" r="5" fill="rgb(30,150,43)"></circle> <circle cx="135.56796817958528" cy="127.40915255930368" r="5" fill="rgb(30,150,35)"></circle> <circle cx="195.72769880316034" cy="203.4027436123629" r="5" fill="rgb(30,150,67)"></circle> <circle cx="130.7530263067129" cy="244.7852266812409" r="5" fill="rgb(30,150,98)"></circle> <circle cx="36.438341384815075" cy="210.6090541896294" r="5" fill="rgb(30,150,139)"></circle> <circle cx="176.71218763469287" cy="137.54323300750582" r="5" fill="rgb(30,150,29)"></circle> <circle cx="174.45032008232968" cy="209.2316111886315" r="5" fill="rgb(30,150,61)"></circle> <circle cx="68.73068617514102" cy="52.28176780869747" r="5" fill="rgb(30,150,142)"></circle> <circle cx="162.4456402979608" cy="73.76239706732053" r="5" fill="rgb(30,150,86)"></circle> <circle cx="108.00141921697366" cy="109.55469140282139" r="5" fill="rgb(30,150,69)"></circle> <circle cx="162.96141476843476" cy="141.23102327916624" r="5" fill="rgb(30,150,16)"></circle> <circle cx="125.9345304765698" cy="238.19247603714848" r="5" fill="rgb(30,150,93)"></circle><line x1="130.64433518067872" y1="28.1630727673696" x2="96.17812624734673" y2="29.840537240648665" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="96.17812624734673" y1="29.840537240648665" x2="67.04524904809107" y2="53.02953597638252" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="67.04524904809107" y1="53.02953597638252" x2="38.82122769921369" y2="75.5662312500352" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="38.82122769921369" y1="75.5662312500352" x2="28.36356558991553" y2="95.4663889254756" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="28.36356558991553" y1="95.4663889254756" x2="18.330634507062157" y2="169.68512490920642" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="18.330634507062157" y1="169.68512490920642" x2="19.797156728201166" y2="208.00327375672293" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="19.797156728201166" y1="208.00327375672293" x2="36.83140136457256" y2="237.10836498299798" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="36.83140136457256" y1="237.10836498299798" x2="132.24331417077946" y2="291.2609993001805" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="132.24331417077946" y1="291.2609993001805" x2="161.10556608174647" y2="287.6615940190875" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="161.10556608174647" y1="287.6615940190875" x2="226.2427629753817" y2="260.4928511647599" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="226.2427629753817" y1="260.4928511647599" x2="282.75471021838604" y2="222.40422121056434" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="282.75471021838604" y1="222.40422121056434" x2="287.55861698920245" y2="191.54124064684203" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="287.55861698920245" y1="191.54124064684203" x2="277.6246746037615" y2="90.30367358125177" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="277.6246746037615" y1="90.30367358125177" x2="251.5850563588106" y2="65.40572671380644" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="251.5850563588106" y1="65.40572671380644" x2="204.0380699117014" y2="37.35498291700646" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="204.0380699117014" y1="37.35498291700646" x2="130.64433518067872" y2="28.1630727673696" style="stroke:rgb(255,0,0);stroke-width:2"></line></svg> - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} ---------------------------------------------------------------------------------------------- --- --- GRAHAM SCAN IMPLEMENTATION --- --- This little haskell programm calulates the Convex Hull for a set of 2D points. --- It ships wit a main function that feeds the Graham Scan algorithm with some --- random points and generates a simple SVG of the input points and resulting envelope. --- A simple SVG encoder is included. --- --- Alogrithm used: https://en.wikipedia.org/wiki/Graham_scan --- --- CREDITS -- --- --- Michal Idziorek <m.i@gmx.at> --- 16 December 2017 --- ---------------------------------------------------------------------------------------------- - -import Data.List -import System.Random - ---------------------------------------------------------------------------------------------- - --- GRAHAM SCAN -- - --- Three points are clockwise if ccw < 0. -ccw (p1x,p1y) (p2x,p2y) (p3x,p3y) = (p2x - p1x)*(p3y - p1y) - (p2y - p1y)*(p3x - p1x) - --- Calculate the slope defined by 2 points. (return Infinity, if points are identical). -slope (ax,ay) (bx,by) | (ax,ay ) == (bx,by) = 1/0 -- Infinity - | otherwise = (bx-ax)/(by-ay) - --- Comparison function to sort points counterclockwise (given a reference point). -slope_cmp a b c = compare (slope a c) (slope a b) - --- Comparison function using the y and x coordinates for ordering. -graham_cmp (ax,ay) (bx,by) | ay /= by = compare ay by - | otherwise = compare ax bx - --- Graham scan on prepared data. this will calculate the convex hull. -graham_calc [] hs = hs -graham_calc (x1:xs) hh | length(hh) < 2 = graham_calc xs (x1:hh) -graham_calc xx@(x1:xs) hh@(h1:h2:hs) | ccw x1 h1 h2 < 0 = graham_calc xs (x1:hh) - | otherwise = graham_calc xx (h2:hs) - --- Find the starting point, sort all points counterclockwise and perform the graham scan. -graham xs = graham_calc sortedPoints [] - where minPoint = minimumBy graham_cmp xs - sortedPoints = sortBy (slope_cmp minPoint) xs - ---------------------------------------------------------------------------------------------- - --- XML ENCODING-- - -xml_attr (x:xs) = x++"=\""++(head xs)++"\" " -xml_enc tag attrs body = "<"++tag++" "++xml_attrs++">"++body++"</"++tag++">" - where xml_attrs = unlines $ map xml_attr attrs - --- SVG ENCODING -- - --- hardcoded scaling and panning function -svg_transf x = x*30+5 - -line_to_svg ((x1,y1),(x2,y2)) = xml_enc "line" [["x1",show lx1],["y1",show ly1], - ["x2",show lx2],["y2",show ly2], - ["style", "stroke:rgb(255,0,0);stroke-width:2"]] "" - where lx1=svg_transf x1 - lx2=svg_transf x2 - ly1=svg_transf y1 - ly2=svg_transf y2 - -point_to_svg (x,y) = xml_enc "circle" [["cx",show cx],["cy",show cy],["r","5"], - ["fill","rgb(30,150,"++(show (floor dist))++")"]] "" - where cx=svg_transf x - cy=svg_transf y - dist= (sqrt ((x-5)*(x-5) + (y-5)*(y-5)))*255/8 - - - --- draws SVG points and lines (in hardcoded sizes and colors) -svg_draw p l = xml_enc "svg" [style,["width","330"],["height","330"]] body - where style = ["style", - "background-color:black;border:3px solid green;margin:2px;"] - body = (unlines (map point_to_svg p )) ++ - (unlines (map line_to_svg l )) - --- calculate convex hull and generate svg -svg_graham xs = svg_draw xs (zip hull hull_open) - where hull_open = graham xs - hull = (last hull_open) : hull_open - --- RANDOMIZING -- - -randomPoints g cnt = take cnt (zip r10a r10b) - where r5 = randomRs (0,5) g :: [Double] - r10a =zipWith (+) r5 (drop cnt r5) - r10b =zipWith (+) (drop (2*cnt) r5) (drop (3*cnt) r5) - ---------------------------------------------------------------------------------------------- - --- MAIN -- - --- Note that this is the only place of impurity in this source-file. --- Is is subject to side effects due to I/O (we are writng to stdout) --- and the random number generator. -main = do - g <- newStdGen - putStr (svg_graham (randomPoints g 25)) - putStr (svg_graham (randomPoints g 50)) - putStr (svg_graham (randomPoints g 100)) - putStr (svg_graham (randomPoints g 250)) - putStr (svg_graham (randomPoints g 500)) - putStr (svg_graham (randomPoints g 1500)) - ---------------------------------------------------------------------------------------------- -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast b/080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast deleted file mode 100644 index b32cd78..0000000 --- a/080_blog/00040_Haskell/00065_Base64-Encoder/base64.cast +++ /dev/null @@ -1,146 +0,0 @@ -{ - "env": { - "TERM": "screen-256color", - "SHELL": "/bin/bash" - }, - "version": 1, - "command": null, - "title": null, - "width": 90, - "height": 7, - "duration": 26.498611, - "stdout": [ - [ - 0.018948, - "miguel@megaloman:~/git/haskell/base64$ " - ], - [ - 0.831467, - "cat /tmp/random.bin | pv | ./base64 > /dev/null " - ], - [ - 0.269283, - "\r\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[C\u001b[17Pecho \"Hello Base64!\" | ./base64" - ], - [ - 1.242802, - "\r\n" - ], - [ - 0.002817, - "SGVsbG8gQmFzZTY0IQo=\r\n" - ], - [ - 0.000531, - "miguel@megaloman:~/git/haskell/base64$ " - ], - [ - 0.827791, - "echo \"Hello Base64!\" | ./base64" - ], - [ - 0.207417, - "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bcat /tmp/random.bin | pv | ./base64 > /dev/null " - ], - [ - 0.963475, - "\r\n" - ], - [ - 1.002914, - " 434MiB 0:00:01 [ 434MiB/s] [ <=> ]\r" - ], - [ - 0.99997, - " 876MiB 0:00:02 [ 441MiB/s] [ <=> ]\r" - ], - [ - 1.000022, - "1.28GiB 0:00:03 [ 439MiB/s] [ <=> ]\r" - ], - [ - 1.000032, - "1.73GiB 0:00:04 [ 455MiB/s] [ <=> ]\r" - ], - [ - 0.999929, - "2.18GiB 0:00:05 [ 464MiB/s] [ <=> ]\r" - ], - [ - 0.999976, - "2.64GiB 0:00:06 [ 464MiB/s] [ <=> ]\r" - ], - [ - 1.000019, - "3.09GiB 0:00:07 [ 466MiB/s] [ <=> ]\r" - ], - [ - 1.00003, - "3.55GiB 0:00:08 [ 467MiB/s] [ <=> ]\r" - ], - [ - 1.0, - "3.99GiB 0:00:09 [ 452MiB/s] [ <=> ]\r" - ], - [ - 0.999962, - "4.43GiB 0:00:10 [ 451MiB/s] [ <=> ]\r" - ], - [ - 1.000027, - "4.88GiB 0:00:11 [ 459MiB/s] [ <=> ]\r" - ], - [ - 1.000061, - "5.32GiB 0:00:12 [ 451MiB/s] [ <=> ]\r" - ], - [ - 0.999986, - "5.76GiB 0:00:13 [ 449MiB/s] [ <=> ]\r" - ], - [ - 0.999944, - "6.19GiB 0:00:14 [ 441MiB/s] [ <=> ]\r" - ], - [ - 0.999991, - "6.64GiB 0:00:15 [ 453MiB/s] [ <=> ]\r" - ], - [ - 1.000027, - "7.07GiB 0:00:16 [ 442MiB/s] [ <=> ]\r" - ], - [ - 1.00001, - " 7.5GiB 0:00:17 [ 442MiB/s] [ <=> ]\r" - ], - [ - 1.000009, - "7.93GiB 0:00:18 [ 440MiB/s] [ <=> ]\r" - ], - [ - 0.999988, - "8.37GiB 0:00:19 [ 449MiB/s] [ <=> ]\r" - ], - [ - 1.000024, - "8.81GiB 0:00:20 [ 445MiB/s] [ <=> ]\r" - ], - [ - 0.99992, - "9.26GiB 0:00:21 [ 461MiB/s] [ <=> ]\r" - ], - [ - 1.000016, - "9.71GiB 0:00:22 [ 461MiB/s] [ <=> ]\r" - ], - [ - 0.129892, - "9.77GiB 0:00:22 [ 451MiB/s] [ <=> ]\r\r\n" - ], - [ - 0.000604, - "miguel@megaloman:~/git/haskell/base64$ " - ] - ] -}
\ No newline at end of file diff --git a/080_blog/00040_Haskell/00065_Base64-Encoder/index.md b/080_blog/00040_Haskell/00065_Base64-Encoder/index.md deleted file mode 100644 index bdbae41..0000000 --- a/080_blog/00040_Haskell/00065_Base64-Encoder/index.md +++ /dev/null @@ -1,21 +0,0 @@ - February 2018 -Miguel's Base64 Encoder -======================= - -Initially coded on a cold winter afternoon to fully understand **base64 encoding** and play with -**Haskell**, which is always an indisputable pleasure. Hacked together in _big anger_, due to my -friend Nick's fairy tales about saving his encrypted binary data in plain _ASCII_ -configuration files,... featuring strange letters and non-printable characters. :smile: - -After optimizing quite a bit, the encoder performs around **460MB/s** on a single core of my _i7-4790K_. - -<asciinema-player loop="1" preload="true" theme="solarized-dark" autoplay="true" src="base64.cast"></asciinema-player> - -The source code below was auto-fetched from: -<https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=blob;f=base64/base64.hs> - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -{BEGIN:EMBED} -https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=blob_plain;f=base64/base64.hs -{END:EMBED} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/080_blog/00040_Haskell/00120_Lambda-Calculus/index.md b/080_blog/00040_Haskell/00120_Lambda-Calculus/index.md deleted file mode 100644 index b86950f..0000000 --- a/080_blog/00040_Haskell/00120_Lambda-Calculus/index.md +++ /dev/null @@ -1,39 +0,0 @@ - May 2018 -Lambda Calculus -=============== - -Playing with Type Quantifiers and Haskell's Rank 2 Type Polymorphsim, -implementing Boolean logic from scratch. We use the conventional -definitions for `True` an `False` also known as Church booleans, after Alonzo Church, who -intruced them along Lambda Calculus in the 1930s [[1]](#ref). - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -{-# LANGUAGE Rank2Types #-} - -fTrue :: forall a. a->a->a -fTrue x y = x - -fFalse :: forall a. a->a->a -fFalse x y = y - -fAnd :: (forall a. a->a->a)->(forall a. a->a->a)->(forall a. a->a->a) -fAnd p q = p q p - -fOr :: (forall a. a->a->a)->(forall a. a->a->a)->(forall a. a->a->a) -fOr p q = p p q - -fNot :: (forall a. a->a->a)->(forall a. a->a->a) -fNot p = p fFalse fTrue - -ifThenElse :: (forall a. a->a->a)->(forall a. a->a->a) - ->(forall a. a->a->a)->(forall a. a->a->a) -ifThenElse p a b = p a b - --- Example -- - -main = print $ (ifThenElse fFalse fFalse $ fAnd fTrue $ fNot fFalse) "T" "F" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Ref - -* [1] <https://en.wikipedia.org/wiki/Lambda_calculus> diff --git a/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/calc.png b/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/calc.png Binary files differdeleted file mode 100644 index 19b47f0..0000000 --- a/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/calc.png +++ /dev/null diff --git a/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md b/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md deleted file mode 100644 index cc0aa28..0000000 --- a/080_blog/00040_Haskell/00130_Calculator-on-Parsec-and-GTK/index.md +++ /dev/null @@ -1,21 +0,0 @@ - May 2018 -Simple Calculator on Parsec and GTK -=================================== - -{ width=220px } - -Today I implemented this simple stupid calulator as a side effect of playing -around with parsec [1] and haskells gtk3 [2] bindings, as well as glade [3] - -an interactive user interface designer. - -Source Files ------------- - -* <https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=tree;f=calcGTK> - -Ref ---- - -* [1] <https://hackage.haskell.org/package/parsec> -* [2] <https://hackage.haskell.org/package/gtk3> -* [3] <https://glade.gnome.org/> diff --git a/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md b/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md deleted file mode 100644 index 2c21d91..0000000 --- a/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/index.md +++ /dev/null @@ -1,27 +0,0 @@ - May 2018 -A Minimalistic SVG Generator -============================ - - - -A minimalistic SVG generator for my humble requirements. -They might grow someday however... - -The SVG in the following screenshot was generated from the following code -to demonstrate a simple use case. - -The source code below was auto-fetched from: -<https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=blob;f=simpleSVG/TestSvg.hs> - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -{BEGIN:EMBED} -https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=blob_plain;f=simpleSVG/TestSvg.hs -{END:EMBED} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -{.img-fluid .border} - -Source Files ------------- - -* <https://gitweb.softwarefools.com/?p=miguel/haskell.git;a=tree;f=simpleSVG> diff --git a/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png b/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png Binary files differdeleted file mode 100644 index d679fad..0000000 --- a/080_blog/00040_Haskell/00140_Minimalistic-SVG-Generator/svg.png +++ /dev/null diff --git a/080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md b/080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md deleted file mode 100644 index 6e4418b..0000000 --- a/080_blog/00040_Haskell/00150_Applicative-vs-Monadic-Parsing/index.md +++ /dev/null @@ -1,175 +0,0 @@ - March 2019 -# Applicative vs. Monadic Parsing - -Some _real world parsers_ as _Parsec_, let us choose between applicative and -monadic parsing. The applicative style should be sufficient to parse -_context-free_ languages and is easier to reason about, but it is not capable -of parsing _context-sensitive_ grammars. - -## Functor, Applicative, Alternative, Monad - -Before we discuss Applicative and Monadic Parsing, it is important to -understand what Functors, Applicative Functors, Alternatives and Monads -have to offer. When in doubt simply look up the type-class definition. - -Two well-known data types which are instances of all of the above are -**Maybe** and **List**. Try it yourself in _GHCi_. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} --- Maybe as Functor -fmap (+20) (Just 10) -fmap (+20) (Nothing) - --- List as Functor -fmap (+20) [1..10] - --- Maybe as Applicative Functor -Nothing <*> Just (22) -Just (+1) <*> Nothing -Just (+15) <*> Just (22) - --- List as Applicative Functor -[]<*>[1..5] -[(+1),(+15)]<*>[] -[(+1),(+15)]<*>[1..5] - --- Maybe as Alternative -Nothing <|> Just 5 -Just 5 <|> Nothing -Just 22 <|> Just 10 - --- List as Alternative -[1..5] <|> [5..10] - --- Maybe as Monad -Just 5 >>= Just . (+10) -Just 5 >>= return . (+10) -Just 10 >>= return . (+5) >>=return . (+10) -Nothing >>= return . (+5) >>=return . (+10) -Just 10 >>= \x-> return (x*2) >>=return . (+x`div`2) - --- List as Monad -[1..10] >>= (:[]) . (*5) -[1..5] >>= return . (^2) -[[1..5],[5..10],[],[12]]>>=id -[[1..5],[5..10],[],[12]]>>= map (*4) -[1..5] >>= \a -> [100..100+a] >>= \b -> return (a+b) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Simple Parser - -Our simple toy Parser simply encapsulates a parsing function that returns -_Nothing_ if parsing fails. Otherwise a _pair_ consisting of the parsed and -unparsed input inside its respective elements. - -Notice that we made our Parser instance of all the type-classes already. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -data Parser a b = Parser (a->Maybe (b,a)) - -instance Functor (Parser a) where - fmap f p = Parser g - where g inp = case parse p inp of Just (x,y) -> Just (f x,y) - _ -> Nothing - -instance Applicative (Parser a) where - pure v = Parser (\inp -> Just (v,inp)) - pg <*> px = Parser g - where g inp = case parse pg inp of Just (f,b) -> parse (fmap f px) b - _ -> Nothing - -instance Alternative (Parser a) where - empty = Parser (\_ -> Nothing) - p1 <|> p2 = Parser g - where g inp = case parse p1 inp of Nothing -> parse p2 inp - x -> x - -instance Monad (Parser a) where - return = pure - p >>= f = Parser g - where g inp = case parse p inp of Just (a,b) -> parse (f a) b - _ -> Nothing - -parse :: Parser a b -> a -> Maybe (b,a) -parse (Parser f) inp = f inp -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Primitives - -We also need at least a minimal set of primitives to parse something. -Note that the primitives can give you the effects of Applicative or -Alternative even if there's no instance (as dmwit pointed out on #haskell). -E.g. the _word_ primitive below, could not be composed, by combining the -_char_ parsers in an applicative style only. - -The _num_ parser makes use of the _some_ combinator which requires our -Parser to be an instance of _Alternative_ as well. _Applicative_ -alone is of limited use in practice since without it, we also lack -the <|> combinator. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -word :: String -> Parser String String -word w = Parser g where l = length w - g inp = if take l inp == w then Just (w,drop l inp) - else Nothing - -satisfy :: (Char -> Bool) -> Parser String Char -satisfy f = Parser g where g (x:xs) | f x = Just (x,xs) - g _ = Nothing - -space :: Parser String Char -space = satisfy (==' ') - -char :: Char -> Parser String Char -char c = satisfy (==c) - -notChar :: Char -> Parser String Char -notChar c = satisfy (/=c) - -num :: Parser String Int -num = read <$> some (satisfy isDigit) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Applicative / Alternative parsing - -Let's parse something! - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} --- well-formed parentheses are the canonical example of a context-free grammar -parsePar = concat <$> some parseP where parseP = word "()" <|> (char '(' *> parsePar <* char ')') -parse parsePar "((()())()())" - --- a simple context-free language with matching pairs of a's and b's, which is not regular -parseAB = (\a x b -> a:x++"b") <$> char 'a' <*> parseAB <*> char 'b' <|> word "ab" -parse parseAB "aaaaabbbbb" - --- parse basic mathematical operations and calulate the results. -parseOp op sig = (pure (op) <* many space <*> num <* many space <* char sig <* many space <*> num ) -parse (parseOp (+) '+' <|> parseOp (-) '-' <|> parseOp (*) '*' <|> parseOp (div) '/') " 111 * 747 " -parse (parseOp (+) '+' <|> parseOp (-) '-' <|> parseOp (*) '*' <|> parseOp (div) '/') "111+747" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Monadic parsing of context-sensitive grammars - -The canonical non-context-free language can not be caputred by applicative parsing anymore: $$\{a^n b^n c^n : n \geqslant 1\}$$ - -The following monadic parser will work here: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -parseABC = length <$> (many $ char 'a') >>= \la -> - length <$> (many $ char 'b') >>= \lb -> - length <$> (many $ char 'c') >>= \lc -> - if la==lb&&lb==lc then pure ("ABCok") else empty - -parse parseABC "aaaaabbbbbccccc" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -## Summary - -As usual, use the simplest tool that will suffice :smile: - -## Ref / Further Reading - -* <http://dev.stephendiehl.com/fun/002_parsers.html> -* <https://eli.thegreenplace.net/2017/deciphering-haskells-applicative-and-monadic-parsers/> -* <https://byorgey.wordpress.com/2012/01/05/parsing-context-sensitive-languages-with-applicative/> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index.md b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index.md deleted file mode 100644 index 5060081..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index.md +++ /dev/null @@ -1,20 +0,0 @@ -# Pandoc Color Themes - -Color-themes for syntax-highlighting obtained from Pandoc. -E.g. To get the pygments theme you need to have some source-code embedded -in your markdown and run: - - stack exec pandoc -- -s file.md --highlight-style pygments - -Then you can extract the css from the resulting standalone html file. -Here you can find my extracted html files for reference: - -* [breezedark](index_breezedark.html) -* [espresso](index_espresso.html) -* [haddock](index_haddock.html) -* [kate](index_kate.html) -* [monochrome](index_monochrome.html) -* [pygments](index_pygments.html) -* [tango](index_tango.html) -* [zenburn](index_zenburn.html) - diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_breezedark.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_breezedark.html deleted file mode 100644 index 6b89b97..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_breezedark.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - background-color: #232629; - color: #7a7c7d; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #7a7c7d; padding-left: 4px; } -div.sourceCode - { color: #cfcfc2; background-color: #232629; } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span. { color: #cfcfc2; } /* Normal */ -code span.al { color: #95da4c; } /* Alert */ -code span.an { color: #3f8058; } /* Annotation */ -code span.at { color: #2980b9; } /* Attribute */ -code span.bn { color: #f67400; } /* BaseN */ -code span.bu { color: #7f8c8d; } /* BuiltIn */ -code span.cf { color: #fdbc4b; } /* ControlFlow */ -code span.ch { color: #3daee9; } /* Char */ -code span.cn { color: #27aeae; } /* Constant */ -code span.co { color: #7a7c7d; } /* Comment */ -code span.cv { color: #7f8c8d; } /* CommentVar */ -code span.do { color: #a43340; } /* Documentation */ -code span.dt { color: #2980b9; } /* DataType */ -code span.dv { color: #f67400; } /* DecVal */ -code span.er { color: #da4453; } /* Error */ -code span.ex { color: #0099ff; } /* Extension */ -code span.fl { color: #f67400; } /* Float */ -code span.fu { color: #8e44ad; } /* Function */ -code span.im { color: #27ae60; } /* Import */ -code span.in { color: #c45b00; } /* Information */ -code span.kw { color: #cfcfc2; } /* Keyword */ -code span.op { color: #cfcfc2; } /* Operator */ -code span.ot { color: #27ae60; } /* Other */ -code span.pp { color: #27ae60; } /* Preprocessor */ -code span.re { color: #2980b9; } /* RegionMarker */ -code span.sc { color: #3daee9; } /* SpecialChar */ -code span.ss { color: #da4453; } /* SpecialString */ -code span.st { color: #f44f4f; } /* String */ -code span.va { color: #27aeae; } /* Variable */ -code span.vs { color: #da4453; } /* VerbatimString */ -code span.wa { color: #da4453; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_espresso.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_espresso.html deleted file mode 100644 index 6b0d627..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_espresso.html +++ /dev/null @@ -1,113 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - background-color: #2a211c; - color: #bdae9d; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #bdae9d; padding-left: 4px; } -div.sourceCode - { color: #bdae9d; background-color: #2a211c; } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { color: #ffff00; } /* Alert */ -code span.an { color: #0066ff; font-weight: bold; font-style: italic; } /* Annotation */ -code span.at { } /* Attribute */ -code span.bn { color: #44aa43; } /* BaseN */ -code span.bu { } /* BuiltIn */ -code span.cf { color: #43a8ed; font-weight: bold; } /* ControlFlow */ -code span.ch { color: #049b0a; } /* Char */ -code span.cn { } /* Constant */ -code span.co { color: #0066ff; font-weight: bold; font-style: italic; } /* Comment */ -code span.do { color: #0066ff; font-style: italic; } /* Documentation */ -code span.dt { text-decoration: underline; } /* DataType */ -code span.dv { color: #44aa43; } /* DecVal */ -code span.er { color: #ffff00; font-weight: bold; } /* Error */ -code span.ex { } /* Extension */ -code span.fl { color: #44aa43; } /* Float */ -code span.fu { color: #ff9358; font-weight: bold; } /* Function */ -code span.im { } /* Import */ -code span.in { color: #0066ff; font-weight: bold; font-style: italic; } /* Information */ -code span.kw { color: #43a8ed; font-weight: bold; } /* Keyword */ -code span.op { } /* Operator */ -code span.pp { font-weight: bold; } /* Preprocessor */ -code span.sc { color: #049b0a; } /* SpecialChar */ -code span.ss { color: #049b0a; } /* SpecialString */ -code span.st { color: #049b0a; } /* String */ -code span.va { } /* Variable */ -code span.vs { color: #049b0a; } /* VerbatimString */ -code span.wa { color: #ffff00; font-weight: bold; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_haddock.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_haddock.html deleted file mode 100644 index 5c5af29..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_haddock.html +++ /dev/null @@ -1,109 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - color: #aaaaaa; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } -div.sourceCode - { } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { color: #ff0000; } /* Alert */ -code span.an { color: #008000; } /* Annotation */ -code span.at { } /* Attribute */ -code span.bu { } /* BuiltIn */ -code span.cf { color: #0000ff; } /* ControlFlow */ -code span.ch { color: #008080; } /* Char */ -code span.cn { } /* Constant */ -code span.co { color: #008000; } /* Comment */ -code span.cv { color: #008000; } /* CommentVar */ -code span.do { color: #008000; } /* Documentation */ -code span.er { color: #ff0000; font-weight: bold; } /* Error */ -code span.ex { } /* Extension */ -code span.im { } /* Import */ -code span.in { color: #008000; } /* Information */ -code span.kw { color: #0000ff; } /* Keyword */ -code span.op { } /* Operator */ -code span.ot { color: #ff4000; } /* Other */ -code span.pp { color: #ff4000; } /* Preprocessor */ -code span.sc { color: #008080; } /* SpecialChar */ -code span.ss { color: #008080; } /* SpecialString */ -code span.st { color: #008080; } /* String */ -code span.va { } /* Variable */ -code span.vs { color: #008080; } /* VerbatimString */ -code span.wa { color: #008000; font-weight: bold; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_kate.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_kate.html deleted file mode 100644 index 03aa0c6..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_kate.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - background-color: #ffffff; - color: #a0a0a0; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #a0a0a0; padding-left: 4px; } -div.sourceCode - { color: #1f1c1b; background-color: #ffffff; } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span. { color: #1f1c1b; } /* Normal */ -code span.al { color: #bf0303; background-color: #f7e6e6; font-weight: bold; } /* Alert */ -code span.an { color: #ca60ca; } /* Annotation */ -code span.at { color: #0057ae; } /* Attribute */ -code span.bn { color: #b08000; } /* BaseN */ -code span.bu { color: #644a9b; font-weight: bold; } /* BuiltIn */ -code span.cf { color: #1f1c1b; font-weight: bold; } /* ControlFlow */ -code span.ch { color: #924c9d; } /* Char */ -code span.cn { color: #aa5500; } /* Constant */ -code span.co { color: #898887; } /* Comment */ -code span.cv { color: #0095ff; } /* CommentVar */ -code span.do { color: #607880; } /* Documentation */ -code span.dt { color: #0057ae; } /* DataType */ -code span.dv { color: #b08000; } /* DecVal */ -code span.er { color: #bf0303; text-decoration: underline; } /* Error */ -code span.ex { color: #0095ff; font-weight: bold; } /* Extension */ -code span.fl { color: #b08000; } /* Float */ -code span.fu { color: #644a9b; } /* Function */ -code span.im { color: #ff5500; } /* Import */ -code span.in { color: #b08000; } /* Information */ -code span.kw { color: #1f1c1b; font-weight: bold; } /* Keyword */ -code span.op { color: #1f1c1b; } /* Operator */ -code span.ot { color: #006e28; } /* Other */ -code span.pp { color: #006e28; } /* Preprocessor */ -code span.re { color: #0057ae; background-color: #e0e9f8; } /* RegionMarker */ -code span.sc { color: #3daee9; } /* SpecialChar */ -code span.ss { color: #ff5500; } /* SpecialString */ -code span.st { color: #bf0303; } /* String */ -code span.va { color: #0057ae; } /* Variable */ -code span.vs { color: #bf0303; } /* VerbatimString */ -code span.wa { color: #bf0303; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_monochrome.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_monochrome.html deleted file mode 100644 index 60c229d..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_monochrome.html +++ /dev/null @@ -1,96 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - } -pre.numberSource { margin-left: 3em; padding-left: 4px; } -div.sourceCode - { } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { font-weight: bold; } /* Alert */ -code span.an { font-style: italic; } /* Annotation */ -code span.cf { font-weight: bold; } /* ControlFlow */ -code span.co { font-style: italic; } /* Comment */ -code span.cv { font-style: italic; } /* CommentVar */ -code span.do { font-style: italic; } /* Documentation */ -code span.dt { text-decoration: underline; } /* DataType */ -code span.er { font-weight: bold; } /* Error */ -code span.in { font-style: italic; } /* Information */ -code span.kw { font-weight: bold; } /* Keyword */ -code span.pp { font-weight: bold; } /* Preprocessor */ -code span.wa { font-style: italic; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_pygments.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_pygments.html deleted file mode 100644 index e637f29..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_pygments.html +++ /dev/null @@ -1,114 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - color: #aaaaaa; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } -div.sourceCode - { } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { color: #ff0000; font-weight: bold; } /* Alert */ -code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ -code span.at { color: #7d9029; } /* Attribute */ -code span.bn { color: #40a070; } /* BaseN */ -code span.bu { } /* BuiltIn */ -code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ -code span.ch { color: #4070a0; } /* Char */ -code span.cn { color: #880000; } /* Constant */ -code span.co { color: #60a0b0; font-style: italic; } /* Comment */ -code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ -code span.do { color: #ba2121; font-style: italic; } /* Documentation */ -code span.dt { color: #902000; } /* DataType */ -code span.dv { color: #40a070; } /* DecVal */ -code span.er { color: #ff0000; font-weight: bold; } /* Error */ -code span.ex { } /* Extension */ -code span.fl { color: #40a070; } /* Float */ -code span.fu { color: #06287e; } /* Function */ -code span.im { } /* Import */ -code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ -code span.kw { color: #007020; font-weight: bold; } /* Keyword */ -code span.op { color: #666666; } /* Operator */ -code span.ot { color: #007020; } /* Other */ -code span.pp { color: #bc7a00; } /* Preprocessor */ -code span.sc { color: #4070a0; } /* SpecialChar */ -code span.ss { color: #bb6688; } /* SpecialString */ -code span.st { color: #4070a0; } /* String */ -code span.va { color: #19177c; } /* Variable */ -code span.vs { color: #4070a0; } /* VerbatimString */ -code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_tango.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_tango.html deleted file mode 100644 index f76564b..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_tango.html +++ /dev/null @@ -1,113 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - color: #aaaaaa; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } -div.sourceCode - { background-color: #f8f8f8; } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { color: #ef2929; } /* Alert */ -code span.an { color: #8f5902; font-weight: bold; font-style: italic; } /* Annotation */ -code span.at { color: #c4a000; } /* Attribute */ -code span.bn { color: #0000cf; } /* BaseN */ -code span.cf { color: #204a87; font-weight: bold; } /* ControlFlow */ -code span.ch { color: #4e9a06; } /* Char */ -code span.cn { color: #000000; } /* Constant */ -code span.co { color: #8f5902; font-style: italic; } /* Comment */ -code span.cv { color: #8f5902; font-weight: bold; font-style: italic; } /* CommentVar */ -code span.do { color: #8f5902; font-weight: bold; font-style: italic; } /* Documentation */ -code span.dt { color: #204a87; } /* DataType */ -code span.dv { color: #0000cf; } /* DecVal */ -code span.er { color: #a40000; font-weight: bold; } /* Error */ -code span.ex { } /* Extension */ -code span.fl { color: #0000cf; } /* Float */ -code span.fu { color: #000000; } /* Function */ -code span.im { } /* Import */ -code span.in { color: #8f5902; font-weight: bold; font-style: italic; } /* Information */ -code span.kw { color: #204a87; font-weight: bold; } /* Keyword */ -code span.op { color: #ce5c00; font-weight: bold; } /* Operator */ -code span.ot { color: #8f5902; } /* Other */ -code span.pp { color: #8f5902; font-style: italic; } /* Preprocessor */ -code span.sc { color: #000000; } /* SpecialChar */ -code span.ss { color: #4e9a06; } /* SpecialString */ -code span.st { color: #4e9a06; } /* String */ -code span.va { color: #000000; } /* Variable */ -code span.vs { color: #4e9a06; } /* VerbatimString */ -code span.wa { color: #8f5902; font-weight: bold; font-style: italic; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_zenburn.html b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_zenburn.html deleted file mode 100644 index f186f69..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/00_pandoc_colors/index_zenburn.html +++ /dev/null @@ -1,113 +0,0 @@ -<!DOCTYPE html> -<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> -<head> - <meta charset="utf-8" /> - <meta name="generator" content="pandoc" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> - <title>index</title> - <style type="text/css"> - code{white-space: pre-wrap;} - span.smallcaps{font-variant: small-caps;} - span.underline{text-decoration: underline;} - div.column{display: inline-block; vertical-align: top; width: 50%;} - </style> - <style type="text/css"> -a.sourceLine { display: inline-block; line-height: 1.25; } -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } -a.sourceLine:empty { height: 1.2em; } -.sourceCode { overflow: visible; } -code.sourceCode { white-space: pre; position: relative; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -code.sourceCode { white-space: pre-wrap; } -a.sourceLine { text-indent: -1em; padding-left: 1em; } -} -pre.numberSource a.sourceLine - { position: relative; left: -4em; } -pre.numberSource a.sourceLine::before - { content: attr(title); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; pointer-events: all; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - } -pre.numberSource { margin-left: 3em; padding-left: 4px; } -div.sourceCode - { color: #cccccc; background-color: #303030; } -@media screen { -a.sourceLine::before { text-decoration: underline; } -} -code span.al { color: #ffcfaf; } /* Alert */ -code span.an { color: #7f9f7f; font-weight: bold; } /* Annotation */ -code span.at { } /* Attribute */ -code span.bn { color: #dca3a3; } /* BaseN */ -code span.bu { } /* BuiltIn */ -code span.cf { color: #f0dfaf; } /* ControlFlow */ -code span.ch { color: #dca3a3; } /* Char */ -code span.cn { color: #dca3a3; font-weight: bold; } /* Constant */ -code span.co { color: #7f9f7f; } /* Comment */ -code span.cv { color: #7f9f7f; font-weight: bold; } /* CommentVar */ -code span.do { color: #7f9f7f; } /* Documentation */ -code span.dt { color: #dfdfbf; } /* DataType */ -code span.dv { color: #dcdccc; } /* DecVal */ -code span.er { color: #c3bf9f; } /* Error */ -code span.ex { } /* Extension */ -code span.fl { color: #c0bed1; } /* Float */ -code span.fu { color: #efef8f; } /* Function */ -code span.im { } /* Import */ -code span.in { color: #7f9f7f; font-weight: bold; } /* Information */ -code span.kw { color: #f0dfaf; } /* Keyword */ -code span.op { color: #f0efd0; } /* Operator */ -code span.ot { color: #efef8f; } /* Other */ -code span.pp { color: #ffcfaf; font-weight: bold; } /* Preprocessor */ -code span.sc { color: #dca3a3; } /* SpecialChar */ -code span.ss { color: #cc9393; } /* SpecialString */ -code span.st { color: #cc9393; } /* String */ -code span.va { } /* Variable */ -code span.vs { color: #cc9393; } /* VerbatimString */ -code span.wa { color: #7f9f7f; font-weight: bold; } /* Warning */ - </style> - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> - <![endif]--> -</head> -<body> -<div class="sourceCode" id="cb1"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb1-1" title="1"><span class="kw">import</span> <span class="dt">Data.Array.Base</span>(unsafeAt)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="kw">import</span> <span class="dt">Data.Bits</span>(shiftL,shiftR,(.&.))</a> -<a class="sourceLine" id="cb1-3" title="3"><span class="kw">import</span> <span class="dt">Foreign.Ptr</span> (plusPtr)</a> -<a class="sourceLine" id="cb1-4" title="4"><span class="kw">import</span> <span class="dt">Foreign.Storable</span> (peek, poke)</a> -<a class="sourceLine" id="cb1-5" title="5"><span class="kw">import</span> <span class="dt">Foreign.ForeignPtr</span> (withForeignPtr)</a> -<a class="sourceLine" id="cb1-6" title="6"><span class="kw">import</span> <span class="dt">System.IO.Unsafe</span> (unsafePerformIO)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"><span class="co">-- |Perform base64 encoding of data from standard input</span></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="ot">main ::</span> <span class="dt">IO</span>()</a> -<a class="sourceLine" id="cb1-10" title="10">main <span class="fu">=</span> BL.getContents<span class="fu">>>=</span>BL.putStr<span class="fu">.</span>BL.fromChunks<span class="fu">.map</span> encode64<span class="fu">.</span>reChunk<span class="fu">.</span>BL.toChunks</a> -<a class="sourceLine" id="cb1-11" title="11"></a> -<a class="sourceLine" id="cb1-12" title="12"><span class="co">-- |Base64 index table </span></a> -<a class="sourceLine" id="cb1-13" title="13"><span class="ot">tab64 ::</span> <span class="dt">UArray</span> <span class="dt">Word32</span> <span class="dt">Word8</span></a> -<a class="sourceLine" id="cb1-14" title="14">tab64 <span class="fu">=</span> array (<span class="dv">0</span>,<span class="dv">63</span>) <span class="fu">$</span> <span class="fu">zip</span> [<span class="dv">0</span><span class="fu">..</span>] <span class="fu">$</span> <span class="fu">map</span> (BI.c2w) <span class="fu">$</span> </a> -<a class="sourceLine" id="cb1-15" title="15"> [<span class="ch">'A'</span><span class="fu">..</span><span class="ch">'Z'</span>]<span class="fu">++</span>[<span class="ch">'a'</span><span class="fu">..</span><span class="ch">'z'</span>]<span class="fu">++</span>[<span class="ch">'0'</span><span class="fu">..</span><span class="ch">'9'</span>]<span class="fu">++</span>[<span class="ch">'+'</span>,<span class="ch">'/'</span>]</a> -<a class="sourceLine" id="cb1-16" title="16"></a> -<a class="sourceLine" id="cb1-17" title="17"><span class="co">-- |Encodes 3 octets into 4 sextets</span></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="ot">enc64 ::</span> (<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)<span class="ot">-></span>(<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>,<span class="dt">Word8</span>)</a> -<a class="sourceLine" id="cb1-19" title="19">enc64 (b1,b2,b3) <span class="fu">=</span> (t <span class="dv">3</span>,t <span class="dv">2</span>,t <span class="dv">1</span>,t <span class="dv">0</span>)</a> -<a class="sourceLine" id="cb1-20" title="20"> <span class="kw">where</span> t x <span class="fu">=</span> tab64 <span class="ot">`unsafeAt`</span> (n <span class="ot">`shiftR`</span> (x<span class="fu">*</span><span class="dv">6</span>) <span class="fu">.&.</span> <span class="dv">63</span>)</a> -<a class="sourceLine" id="cb1-21" title="21"> f b n <span class="fu">=</span> <span class="fu">fromIntegral</span> b <span class="ot">`shiftL`</span> n</a> -<a class="sourceLine" id="cb1-22" title="22"> n <span class="fu">=</span> f b1 <span class="dv">16</span> <span class="fu">+</span> f b2 <span class="dv">8</span> <span class="fu">+</span> f b3 <span class="dv">0</span></a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co">-- |Transforms list of ByteStrings to a new list of ByteStrings with </span></a> -<a class="sourceLine" id="cb1-25" title="25"><span class="co">-- lengths guaranteed to be multiples of 3 (excepting the last one)</span></a> -<a class="sourceLine" id="cb1-26" title="26"><span class="co">-- Assumes that all input ByteStrings (excepting the last one) have </span></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co">-- at least a length of 3.</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="ot">reChunk ::</span> [<span class="dt">BS.ByteString</span>] <span class="ot">-></span> [<span class="dt">BS.ByteString</span>]</a> -<a class="sourceLine" id="cb1-29" title="29">reChunk (y<span class="fu">:</span>[]) <span class="fu">=</span> [y]</a> -<a class="sourceLine" id="cb1-30" title="30">reChunk (y<span class="fu">:</span>z<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> c <span class="fu">=</span> BS.length y <span class="ot">`mod`</span> <span class="dv">3</span> </a> -<a class="sourceLine" id="cb1-31" title="31"> <span class="kw">in</span> BS.append y (BS.take <span class="dv">3</span> z)<span class="fu">:</span>(reChunk <span class="fu">$</span> (BS.drop <span class="dv">3</span> z)<span class="fu">:</span>zs)</a></code></pre></div> -</body> -</html> diff --git a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md b/080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md deleted file mode 100644 index a66c99c..0000000 --- a/080_blog/00040_Haskell/00200_Estatico-Page-Maker/index.md +++ /dev/null @@ -1,63 +0,0 @@ - April 2018 -# estático - static website generator - -A few weeks ago I decided to switch my website from a well known PHP -driven CMS solution, to a light and static set of HTML pages. - -And so I wrote ... a simple static website generator in **Haskell**. -Of course I know that there are plenty of these out there, still I wanted -my very own masturbatory solution. - -I use **pandoc** et al. for most of the work anyway. - -## Features - -* **No** Database -* Generate HTML from **Markdown** with **pandoc** -* **Highlight** source-code with **pandoc** -* Embed data **fetched** from the web with **http-conduit** -* Embed **screen-casts** with **asciinema** -* Embed Latex formulas with **MathJx** -* Scale Images with **ImageMagick** -* Generate MP4 from OGG **Videos** with **ffmpeg** - -## Try It -You can find the most recent version following the links below. -Build it with _stack_ or use the docker images. - -* <https://gitweb.softwarefools.com/?p=miguel/estatico.git> -* <https://github.com/miguelclean/estatico> -* <https://hub.docker.com/r/migueldirty/estatico/builds> - -## Pandoc Themes - -Here I put together the themes available for syntax-highlighting, extracted -from **pandoc**: [./pandoc\_colors](./pandoc_colors) - -## Example Website - -This very website <https://www.idziorek.net> is a real-world example making -use of estático. You can find it's sources here: - -* <https://gitweb.softwarefools.com/?p=miguel/idziorek_net.git> - -## Example Usage (Docker) - -__NOTE: make sure DIR\_OUT exists and is a free directory__ - -You can use the example websites inside the examples/ directory for a start. - -Inside the input directory (e.g. ./examples/example01/) run something along this lines: - - DIR_IN=`pwd` - DIR_OUT=/mnt/yourwebsiteroot - HTML_ROOT=https://www.example.com - SUDO=sudo - IMAGE=migueldirty/estatico - ${SUDO} docker run --rm -v${DIR_IN}:/in:ro -v${DIR_OUT}:/out:rw ${IMAGE} /in /out ${HTML_ROOT} - -Or if you want to test it locally use some local DIR\_OUT and HTML\_ROOT instead: - - DIR_OUT=/home/miguel/testpage - HTML_ROOT=/home/miguel/testpage - diff --git a/080_blog/00040_Haskell/00_00150_Applicative-vs-Monadic-Parsing/index.md b/080_blog/00040_Haskell/00_00150_Applicative-vs-Monadic-Parsing/index.md deleted file mode 100644 index f9b3a4e..0000000 --- a/080_blog/00040_Haskell/00_00150_Applicative-vs-Monadic-Parsing/index.md +++ /dev/null @@ -1 +0,0 @@ -Coming sooner... or later. diff --git a/080_blog/00040_Haskell/index.md b/080_blog/00040_Haskell/index.md deleted file mode 100644 index 2c02a65..0000000 --- a/080_blog/00040_Haskell/index.md +++ /dev/null @@ -1,8 +0,0 @@ -Haskell -======= - -Originally coming from structured and object-oriented programming, I fell -in love with Haskell a couple of years ago. I appreciate it's purity -and laziness and the powerful, static type system. - -You can find here my notes and tiny toy projects related to Haskell. |
