Skip to content

Instantly share code, notes, and snippets.

View paolino's full-sized avatar

Paolo Veronelli paolino

  • Cardano Foundation
  • albufeira, portugal
View GitHub Profile
@paolino
paolino / withAlternative.hs
Created October 3, 2011 17:15
Using Alternative <|> to fold nested if
import Control.Monad
import Control.Applicative
checkProperty = undefined
getDmgMult t elem = maybe 1 id $ do
e <- elem
let check f = checkProperty t ((==e) . f) >>= guard
(check succ >> return 2) `mplus` (check pred >> return 0.5)
import System.Exit ( exitWith, ExitCode(ExitSuccess) )
import Graphics.UI.GLUT
import Foreign.Marshal.Array
myInit :: IO ()
myInit = do
clearColor $= Color4 0 0 0 0
display :: DisplayCallback
display = do
import Prelude hiding (writeFile)
import Data.ByteString.Lazy hiding (map, putStrLn, putStr)
import Data.ByteString.Internal
import Network.HTTP
import Control.Monad (when)
import Data.Time.Clock
import System.FilePath
import System.IO hiding (writeFile)
import Control.Concurrent
{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
import Data.Map (Map, unionWith)
class Box b a where
insert :: a -> b -> b
delete :: a -> b -> b
slide :: Box b a => a -> a -> b -> b
{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
import Data.Map (Map, unionWith, fromList, elems, assocs, size)
import Control.Monad ((>=>))
import Data.List (mapAccumL)
import Control.Arrow (second)
class Box b a where
insert :: a -> b -> b
delete :: a -> b -> b
@paolino
paolino / topsort.hs
Last active December 23, 2015 15:09
A topological sort algorythm based on edge defined graph. Complexity is O (n^2)
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative ((<*>))
import Data.List (partition,filter, nub)
-- Una dipendenza è una coppia di valori dello stesso tipo
type Dipendenza a = (a,a)
-- il primo valore della coppia è quello dipendente
dipendente (x,y) = x
@paolino
paolino / Generating SVG using AngularJS.markdown
Created December 30, 2015 16:58
Generating SVG using AngularJS
@paolino
paolino / Lambda.hs
Last active April 26, 2016 21:38
Lambda calculus description with beta reduction
{-#LANGUAGE StandaloneDeriving,MultiParamTypeClasses,GeneralizedNewtypeDeriving,ViewPatterns, DeriveFunctor #-}
import Data.List (nub)
import Control.Monad.Reader (runReader, local, asks, liftM2, Reader, MonadReader)
-- Lambda expressions
data Expr a = T a -- terminal name
| a :-> Expr a -- lambda parameter abstraction
| Expr a :$ Expr a -- expression composition
@paolino
paolino / cacheEventDraft.hs
Last active May 6, 2016 14:54
caching reflex widget event creation
------------- Spider synonims
type ES = Event Spider
type DS = Dynamic Spider
-------------- Dom + spider synonyms
type MS = MonadWidget Spider
@paolino
paolino / Readme_NIX_OS.md
Created May 18, 2016 04:43 — forked from i-e-b/Readme_NIX_OS.md
/etc/nixos/configuration.nix

My experiments with an XMonad setup in NixOS. This is my work box now, so it pretty much works.

probably needs:

# useradd -m iain
# passwd iain ...
# passwd root ...