Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nonowarn committed May 3, 2010
1 parent c820b76 commit 33259ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
43 changes: 28 additions & 15 deletions src/Data/Has.hs
Expand Up @@ -14,23 +14,25 @@

module Data.Has
(
-- * Core
(&), (:&:), row
, Has(..), Row
, upd
-- * Has class
Has

-- * Working with labelled values
, Labelled(), (:>), (.>)
, Knows(..), updl
-- * Rows in records
, Row
, (&), (:&:), row

-- ** And aliases
-- * Update and Lookup values from records
, (^=), (^.), (^:)
, Knows(..), updl

-- * Labelled values
, Labelled(), (:>), (.>)

-- ** Defining labels
, TypeOf, RowOf, rowOf

-- * Make parsing error messages easier
, (:::), TyNil()
, (:::)(), TyNil(), Contains()
) where

import Control.Applicative
Expand Down Expand Up @@ -80,29 +82,40 @@ updl :: (Knows lab b a)
=> lab -> (b -> b) -> (a -> a)
updl lab f a = let b = prjl lab a in injl lab (f b) a

-- | TypeOf @a@ should indicate a type labelled by @a@
type family TypeOf a

-- | > RowOf a == a :> TypeOf a
type family RowOf a
type instance RowOf a = a :> TypeOf a

-- | Creates a row labelled by @a@
rowOf :: TypeOf a -> RowOf a
rowOf a = undefined .> a

-- | Same as @Knows lab (TypeOf lab) s@, Useful on writing type
-- signitures.
--
-- Holds @e == (lab .^ (lab ^= e $ s))@
-- where @lab :: lab; e :: TypeOf lab; s :: s@
class (Knows lab (TypeOf lab) s) => Has lab s
instance (Knows lab (TypeOf lab) s) => Has lab s

-- | Opeartor version of 'injl'
(^=) :: (Knows lab (TypeOf lab) s) => lab -> TypeOf lab -> s -> s
-- | Strict version of 'injl'
(^=) :: (Knows lab (TypeOf lab) s)
=> lab -> TypeOf lab -> s -> s
(^=) = injl
infix 6 ^=

-- | Operator version of 'prjl'
(^.) :: (Knows lab (TypeOf lab) s) => lab -> s -> TypeOf lab
-- | Strict version of 'prjl'
(^.) :: (Knows lab (TypeOf lab) s)
=> lab -> s -> TypeOf lab
(^.) = prjl
infix 4 ^.

-- | Operator version of 'updl'
(^:) :: (Knows lab (TypeOf lab) s)=> lab -> (TypeOf lab -> TypeOf lab) -> (s -> s)
-- | Strict version of 'updl'
(^:) :: (Knows lab (TypeOf lab) s)
=> lab -> (TypeOf lab -> TypeOf lab) -> (s -> s)
(^:) = updl
infixr 5 ^:

Expand Down
4 changes: 2 additions & 2 deletions src/Data/Has/Engine.hs
Expand Up @@ -13,8 +13,8 @@ type Row a = a ::: TyNil
row :: a -> Row a
row a = a ::: TyNil

-- | Concatenates between 'Row's or records. Records means
-- concatenations of rows. For example, Following expressions are
-- | Concatenates between 'Row's or records. Records are
-- concatenated rows. For example, Following expressions are
-- valid.
--
-- > -- Concatenation of rows (i.e. record)
Expand Down

0 comments on commit 33259ba

Please sign in to comment.