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 / gol.hs
Last active November 17, 2019 09:32
game of life take
{-# LANGUAGE ViewPatterns, NoMonomorphismRestriction #-}
-- |
-- - one cell to cell interaction per cycle only when at least one of them is alive
module Main where
import qualified Data.Set as S
import Data.Set ( Set )
@paolino
paolino / working hours spreadsheet.md
Last active November 7, 2019 08:54
A spreadsheet to track your activity in a month
{-# LANGUAGE GADTs #-}
--------------------------------------------------------------------------------
-- U can use Control.Free.Applicative here, but implement them for your good
--------------------------------------------------------------------------------
data Ap f b where
APure :: b -> Ap f b
Ap ::f a -> Ap f (a -> b) -> Ap f b
@paolino
paolino / DeepMapPrincipled.hs
Created October 19, 2019 18:51
a version with MapD and MapE factored out to MakeDeepMap
-- |
-- Module : DeepMap
-- Copyright : Paolo Veronelli, 2019
-- License : BSD3
--
-- Maintainer : paolo.veronelli@gmail.com
-- Stability : experimental
-- Portability : unknown
--
-- diffs of polytyped nested maps a.k.a. deepmap
@paolino
paolino / DeepMap.hs
Last active October 19, 2019 18:52
polytype deep maps, differences, dependent type programming
-- |
-- Module : DeepMap
-- Copyright : Paolo Veronelli, 2019
-- License : BSD3
--
-- Maintainer : paolo.veronelli@gmail.com
-- Stability : experimental
-- Portability : unknown
--
-- diffs of polytyped nested maps a.k.a. deepmap
@paolino
paolino / monoidal_laws.hs
Created May 3, 2019 05:22
monoidal laws
import Test.HUnit
import Control.Monad
testMonoid :: Monoid a => Eq a => Show a => [a] -> Test
testMonoid ms
= test
[ "associativity" ~: sequence_
[(m1 <> m2) <> m3 @?= m1 <> (m2 <> m3)
| [m1, m2, m3] <- replicateM 3 ms
]
@paolino
paolino / romans.hs
Last active April 12, 2019 20:50
parsing roman numbers
-- FSM parser for roman numerals from 0 to 3999
module Lib where
import Protolude hiding (Symbol, State)
import Data.List (lookup)
import qualified Data.Map as M
-- roman symbols, we use them badly as symbols and levels (only some)
data Symbol = M | C | X | I | D | L | V deriving (Show, Enum, Eq, Read, Ord)
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
data Free f a = Layer (f (Free f a)) | Bottom a
deriving instance Functor f => Functor (Free f)
instance Functor f => Applicative (Free f) where
data Q5 a b = Q51 a (Identity b) | Q52 [b]
lq5Twan :: Applicative f => (b -> f b') -> Q5 a b -> f (Q5 a b')
lq5Twan f (Q51 a bs) = Q51 a <$> traverse f bs
lq5Twan f (Q52 bs) = Q52 <$> traverse f bs
data BT tt tt' b t t' a = BT1 (tt -> b) (t a) | BT2 (tt' -> b) (t' a) deriving (Functor,Foldable,Traversable)
runBT (BT1 f x) = f x
runBT (BT2 f x) = f x

Keybase proof

I hereby claim:

  • I am paolino on github.
  • I am paolino (https://keybase.io/paolino) on keybase.
  • I have a public key ASBUdJk9dhVYe7xTBlodV5Yvei1ahLeY14xmFf2Rl_vs3wo

To claim this, I am signing this object: