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 / STM_semantics.hs
Created October 24, 2009 10:40
an exmaple showing STM semantics
import Control.Concurrent
import Control.Concurrent.STM
main = do
c <- atomically $ newTChan :: IO (TChan ())
r <- atomically $ newTVar False
forkIO $ do
atomically $ do
r0 <- readTVar r
case r0 of
import Control.Monad.State
import Data.List
type Count = Int
data Jolly a = None | Given a | Internal (a -> Bool) | Placed Int a
pick :: Eq a => (a -> Bool) -> [a] -> StateT (Int, Jolly a) [] [a]
pick k cs = do
(i, mj) <- get
let more = case mj of
{-# LANGUAGE ExistentialQuantification #-}
-- hacked from roberto tazzoli experiment --
module Svg (renderSvg) where
import Data.List (intercalate)
import System.Random (randomRIO)
import Control.Monad (liftM2, replicateM)
data EBox = forall a . Show a => E String a

Curriculum vitae di Paolo Veronelli (paolino)

  • Nato a Milano il 22 Ottobre 1970
  • 1989: Maturità scientifica presso il Liceo G.B. Vico
  • 1990-1992: Studi presso il politecnico di Milano, ingegneria nucleare. Analisi I , II, Fisica I , II, Geometria e Programmazione Calcolatori.
  • 1992-1997: Viaggi in Europa inframezzati da studi presso la facoltà di Fisica di Bologna e sviluppo di programmi di calcolo numerico in C, C++ e Java.
  • 1998: Trasferimento in montagna e inizio della attività contadina.
  • 2001: Sviluppo di applicazioni in Python per lo scheduling delle risorse all'interno delle fabbriche metalmeccaniche.
  • 2003: Calcolo dello sviluppo dello specchio parabolico riflettore per l'illuminazione del cavo orale.
import Prelude hiding (reverse)
import Control.Arrow (first)
import Data.Set (Set)
import qualified Data.Set as S
import Data.Monoid (Monoid, mappend, mempty)
import Hakyll.Core.DirectedGraph
-- | This data structure represents the state of the dependency analyzer. It
-- holds a complete graph in 'analyzerGraph', which always contains all items,
module Dependencies (Analyzer (..), mkAnalyzer, News, Build, Graph) where
import Data.Set (Set)
import qualified Data.Set as S
import qualified Data.Map as M
import Control.Arrow ((&&&))
import Control.Applicative ((<$>))
import Data.Monoid (Monoid, mappend, mempty)
import DirectedGraph
-- | Pure item Selector
type Mask a = a -> Bool
-- | Build record, containing an action to build an item, and the dependencies.
--
-- The return value of the action computed in its monad is a set of created resources,
-- along with their compiler.
--
@paolino
paolino / Manager.hs
Created April 5, 2011 12:56
Pure interface for hakyll dependency analysis
module Manager where
-- | Yielded values from a manager. The constructor tagging mark the item for the client to act accordingly
data Yield a
= Uptodate a -- ^ this item is uptodate
| Unlink a -- ^ this item must be eliminated
| Build a -- ^ this item must be built
| Empty -- ^ the manager has no item to manage
-- | Create method. Index and value associated is given along dependency logic and existential dependency, if present.
@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