Skip to content

Instantly share code, notes, and snippets.

Hi I'm trying to ressurect this code:
https://www.schoolofhaskell.com/user/edwardk/cellular-automata/part-1
I have resolved everything except this bit:
grid :: [[Bool]] -> Diagram SVG R2
grid = cat unitY . reverse . map (hcat . map cell) where
cell b = unitSquare D.# fc (if b then black else white)
@fragamus
fragamus / gist:ae85e57ec1c3ccdfec26c626011e91da
Created November 13, 2018 03:35
Can someone walk me through this error
• Couldn't match type ‘svg-builder-0.1.1:Graphics.Svg.Core.Element’
with ‘blaze-markup-0.8.2.2:Text.Blaze.Internal.MarkupM ()’
Expected type: QDiagram SVG V2 Double Any
-> blaze-markup-0.8.2.2:Text.Blaze.Internal.Markup
Actual type: QDiagram SVG V2 Double Any -> Result SVG V2 Double
• In the second argument of ‘(.)’, namely
‘renderDia SVG (SVGOptions (mkWidth 400) Nothing "" [] True)’
In the second argument of ‘(.)’, namely
‘renderSvg
. renderDia SVG (SVGOptions (mkWidth 400) Nothing "" [] True)’
@fragamus
fragamus / gist:889030f241f0956bdb630c8305ad8c76
Created November 12, 2018 20:24
Need to walk through this error with someone
I'm trying to bring up the code in Ed Kmett's excellent blog post:
https://www.schoolofhaskell.com/user/edwardk/cellular-automata/part-1
But I get this error:
• Expected kind ‘((* -> *) -> Constraint) -> *’,
but ‘Diagram SVG’ has kind ‘*’
• In the type signature: grid :: [[Bool]] -> Diagram SVG R2
|
git config --global user.name "Michael Gough"
git config --global user.email innovative.engineer@gmail.com
git init
git add .
git commit
curl -u 'fragamus' https://api.github.com/user/repos -d '{"name":"tokamak"}'
enter password
@fragamus
fragamus / some.hs
Last active September 19, 2018 04:47
Existential
{-# LANGUAGE GADTs #-}
import Data.Some
data ZeroOneTwo a where
Zero :: ZeroOneTwo ()
One :: Int -> ZeroOneTwo Int
Two :: (Int,Int) -> ZeroOneTwo Int
getSome :: Some ZeroOneTwo
@fragamus
fragamus / gist:9e472a78922c58b420bc164d06fa7645
Created September 13, 2018 23:58
So withSome just identifies the selector right
import Data.Some
asdf :: forall a. Maybe a -> Bool
asdf (Just _) = True
asdf Nothing = False
test1 = withSome (This (Just 5)) asdf
test2 = withSome (This Nothing) asdf
@fragamus
fragamus / main.hs
Created September 13, 2018 05:04
deriving FromJSON and ToJSON for Literal
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
import Data.Aeson
import Data.Text
import Control.Applicative
-- I want to make this code nice and crisp for teaching purposes
list_of_lists_of_tack_on_functions = (fmap (\x->(++[x]))) <$>
(["0","1","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]!!) <$>
(\x->(read [x])::Int) <$>
"4742836"
foldl (\list_of_names list_of_tack_on_functions -> list_of_tack_on_functions <*> list_of_names)
[""]
list_of_lists_of_tack_on_functions
I need to patchelf this pre-built binary to run on my 64 bit intel nixos machine:
$ file foo
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.0, stripped
$ readelf -d foo
Dynamic section at offset 0x128f8 contains 21 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libm.so.6]
@fragamus
fragamus / gist:ec3499123867e96485a564ddc26442c4
Last active June 22, 2018 08:37
file exists but bash says it does not
$ ls -l /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
-rwxrwxrwx 1 2504 2504 79636 Mar 7 2002 /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
$ /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
bash: /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis: No such file or directory
I DISCOVERED THAT THE EXECUTABLE IS 32 BIT:
$ file /root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis
/root/scipoptsuite-5.0.1/hmetis-1.5-linux/hmetis: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.0.0, stripped