lude

Haskell prelude alternative
git clone git://git.rr3.xyz/lude | git clone gits://git.rr3.xyz/lude
Log | Files | Refs | README | LICENSE

Discrete.hs (736B)


      1 module Lude.Algebra.Category.Discrete (
      2     Discrete (..),
      3 ) where
      4 
      5 import Lude.Algebra.Category.Core
      6 import Lude.Haskell
      7 
      8 -- TODO: Discrete is a groupoid.
      9 
     10 --------------------------------------------------------------------------------
     11 
     12 type Discrete :: forall k. Cat k
     13 data Discrete _ _ where
     14     MkDiscrete :: forall a. Discrete a a
     15 
     16 instance Categorical Discrete where
     17     identity = MkDiscrete
     18     compose MkDiscrete MkDiscrete = MkDiscrete
     19 
     20 instance Functorial (Discrete a) where
     21     type Dom (Discrete a) = Discrete
     22     type Cod (Discrete a) = Function
     23     map = compose
     24 
     25 instance Functorial Discrete where
     26     type Dom Discrete = Dual Discrete
     27     type Cod Discrete = Discrete ==> Function
     28     map (MkDual f) = Naturally (. f)