# i’m back…

sorry folks… it’s been too long. i’m back with you again after a long break from blog world. i’ll try to keep you up to date for the remaining pavement shows. this weekend, we’re in montreal for the osheaga festival. next weekend we are in japan, and… Continua a leggere

Pubblicato in Senza categoria

# The universal space

Take (or imagine) a blank sheet of paper. This is a plane. You can put points and vectors on it. A vector connects two points, but it is “movable”: if you can translate one vector into another, they are deemed equal. A vector doesn’t really have a begi… Continua a leggere

Pubblicato in Senza categoria

# Kind polymorphism in action

Ultrecht Haskell Compiler is an experimental Haskell compiler that supports polymorphism on the kind level. This means that in

`data Eq a b = Eq (forall f. f a -> f b)`

Eq is given kind

`Eq :: forall a . a -> a -> *`

and both Eq Integer Char and Eq [] Maybe are valid types.

Using kind polymorphism, it is possible to write sigfpe’s From monoids to monads using a single type class.

To talk about monoids, you need a category (mor), multiplication (mul) and a unit.

`class Monoid mor mul unit m where  one :: mor unit m  mult :: mor (mul m m) m`

With mor being (->), mul being (,), unit being () this is a normal monoid (one :: () -> m and mult :: (m,m) -> m.). For example:

`instance Monoid (->) (,) () Integer where  one () = 1  mult = uncurry (*)`

Now, instead of functions, there will be natural transformations; instead of (,) there will be functor composition; instead of unit there will be identity functor.

`data Nat f g = Nat (forall x. f x -> g x)data Comp f g x = Comp (f (g x))data Id x = Id xNat :: (* -> *) -> (* -> *) -> *Comp :: (* -> *) -> (* -> *) -> * -> *Id :: * -> *`

And here is the list monad. Notice kinds are different than in the previous case, but it is still an instance of the same type class.

`instance Monoid Nat Comp Id [] where  one = Nat \$ \(Id x) -> [x]              -- one :: Nat Id []  mult = Nat \$ \(Comp x) -> concat x      -- mult :: Nat (Comp [] []) []`

So, monads are really monoids in category of endofunctors.

If you invert the arrows, you get a comonad. Here’s the product comonad.

`data CoNat f g = CoNat (forall x. g x -> f x)data CoComp f g x = CoComp (g (f x))CoNat :: (* -> *) -> (* -> *) -> *CoComp :: (* -> *) -> (* -> *) -> * -> *data Product w a = Product w ainstance Monoid CoNat CoComp Id (Product w) where  one = CoNat \$ \(Product a b) -> Id b  mult = CoNat \$ \(Product a b) -> CoComp \$ Product a (Product a b)`

Question: what are kinds of mor, mul, unit and m in the Monoid type class definition?

There’s a small lie here: monads require also a liftM/fmap function. Not all Haskell types of * -> * are functors, and I used that as a poor replacement.

I didn’t write monoid laws, which if translated happen to be monad laws. You’re welcome to read sigfpe’s original post. It’s hard to write them generically since there’s no access to fmap.

The code is available on hpaste and can be run in UHC. Continua a leggere

Pubblicato in Senza categoria

# Back online

Yup, fixed it. Home PC is back online. Got some major catching up to do now to get the final 40k video up and running then I’m in the clear with you guys – right?? I hope so ! Then its just a case of “what next” Continua a leggere

Pubblicato in Senza categoria

# Firmen Urlaub 2010

Von 26.7.2010 bis 6.8.2010 hat Firma ALU.PLAST s.r.o. firmen Urlaub

Während der Urlaub rufen Sie bitte an

Handy : +420 603/544 049 Continua a leggere

Pubblicato in Senza categoria

# Well thanks a lot Marvell !

Marvell WA-T2.I hate that little make and model number above because I’ve been googling my brains out trying to find a windows 7 64 bit driver for that archaic wireless card for ages. It is not supported so I’ve had to buy a new one which will be with… Continua a leggere

Pubblicato in Senza categoria

# Chemicals to Avoid, Part 5: Nitrosamine Contamination

Numerous authorities link nitrosamines to cancer. They are listed as possible human carcinogens by the EPA, the International Agency for Research on Cancer, the U.S. National Toxicology Program Report on Carcinogens and the California EPA Propositio… Continua a leggere

Pubblicato in Senza categoria

# Chemicals to Avoid, Part 4: Formaldehyde Donors

Formaldehyde, most commonly associated with embalming fluid, is a known carcinogen. Its highly toxic nature makes it an effective preservative in cosmetics, too. While it’s not typically listed in an ingredients list on its own, a number of preservat… Continua a leggere

Pubblicato in Senza categoria