Oct. 3rd, 2012

juan_gandhi: (Default)
https://dorchard.wordpress.com/2011/10/18/subcategories-in-haskell-exofunctors/

{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}

import qualified Data.Set as Set

class ExoFunctor f where
   type SubCat f x :: Constraint
   fmap :: (SubCat f a, SubCat f b) => (a -> b) -> f a -> f b

instance ExoFunctor Set.Set where
   type SubCat Set.Set x = Ord x
   fmap = Set.map

instance ExoFunctor [] where
    type SubCat [] a = ()
    fmap = map

Требует GHC 7.6

(10x [livejournal.com profile] nponeccop)

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

September 2025

S M T W T F S
 1 2345 6
78 910111213
14151617181920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 9th, 2025 08:03 pm
Powered by Dreamwidth Studios