Skip to content

Instantly share code, notes, and snippets.

@michalc
michalc / sudoku.hs
Created Dec 31, 2017
Haskell Sudoku solver
View sudoku.hs
import Control.Lens
import Control.Monad.Loops
import Control.Monad.State.Strict
import Data.List
import Data.List.Split
import Data.Maybe
data SudokuValue = S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 deriving (Eq, Enum)
instance Show SudokuValue where
show s = show $ fromJust (s `elemIndex` [S1 ..]) + 1
@michalc
michalc / echoDelay.hs
Created Feb 26, 2017
Simple delayed echo server in Haskell that accepts multiple connections
View echoDelay.hs
import Network.Socket hiding (send, sendTo, recv, recvFrom)
import Network.Socket.ByteString
import Control.Concurrent
port = 4242
incomingBufferSize = 4096
delayMicroseconds = 500000
main = do
-- Listen
@michalc
michalc / echo.hs
Last active Feb 26, 2017
Simple echo server in Haskell that accepts multiple connections
View echo.hs
import Network.Socket hiding (send, sendTo, recv, recvFrom)
import Network.Socket.ByteString
import Control.Concurrent
port = 4242
incomingBufferSize = 4096
main = do
-- Listen
sock <- socket AF_INET Stream 0