packages feed

family-tree 0.1.2 → 0.2

raw patch · 2 files changed

+42/−29 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.FamilyTree: ID :: Int -> ID
- Data.FamilyTree: newtype ID
+ Data.FamilyTree: EventID :: Int -> EventID
+ Data.FamilyTree: FamilyID :: Int -> FamilyID
+ Data.FamilyTree: PersonID :: Int -> PersonID
+ Data.FamilyTree: newtype EventID
+ Data.FamilyTree: newtype FamilyID
+ Data.FamilyTree: newtype PersonID
- Data.FamilyTree: addEvent :: FamilyTree -> (FamilyTree, ID)
+ Data.FamilyTree: addEvent :: FamilyTree -> (FamilyTree, EventID)
- Data.FamilyTree: addFamily :: FamilyTree -> (FamilyTree, ID)
+ Data.FamilyTree: addFamily :: FamilyTree -> (FamilyTree, FamilyID)
- Data.FamilyTree: addPerson :: FamilyTree -> (FamilyTree, ID)
+ Data.FamilyTree: addPerson :: FamilyTree -> (FamilyTree, PersonID)
- Data.FamilyTree: deleteEvent :: ID -> FamilyTree -> FamilyTree
+ Data.FamilyTree: deleteEvent :: EventID -> FamilyTree -> FamilyTree
- Data.FamilyTree: deleteFamily :: ID -> FamilyTree -> FamilyTree
+ Data.FamilyTree: deleteFamily :: FamilyID -> FamilyTree -> FamilyTree
- Data.FamilyTree: deletePerson :: ID -> FamilyTree -> FamilyTree
+ Data.FamilyTree: deletePerson :: PersonID -> FamilyTree -> FamilyTree
- Data.FamilyTree: eventLens :: ID -> Lens FamilyTree Event
+ Data.FamilyTree: eventLens :: EventID -> Lens FamilyTree Event
- Data.FamilyTree: familyLens :: ID -> Lens FamilyTree Family
+ Data.FamilyTree: familyLens :: FamilyID -> Lens FamilyTree Family
- Data.FamilyTree: personLens :: ID -> Lens FamilyTree Person
+ Data.FamilyTree: personLens :: PersonID -> Lens FamilyTree Person

Files

family-tree.cabal view
@@ -1,5 +1,5 @@ name:           family-tree-version:        0.1.2+version:        0.2 cabal-version:  >= 1.2 build-type:     Simple author:         Nathan "Taneb" van Doorn
src/Data/FamilyTree.hs view
@@ -13,25 +13,32 @@  -} module Data.FamilyTree- (-- * Main types+ (+ -- * Types+ -- ** Main types  Person(..),  Family(..),  Event(..),  FamilyTree(..),- -- * Other types+ -- ** ID types+ -- $ids+ PersonID(..),+ FamilyID(..),+ EventID(..),+ -- ** Other types  Location(..),  Relationship(..),- ID(..),- -- * Creation+ -- * Functions+ -- ** Creation  newTree,  addPerson,  addFamily,  addEvent,- -- * Manipulation+ -- ** Manipulation  personLens,  familyLens,  eventLens,- -- * Destruction+ -- ** Destruction  deletePerson,  deleteFamily,  deleteEvent@@ -221,17 +228,23 @@       ,events = e       } --- | ID represents an identifier for a person, family, or event. While the--- constructor is exported, it is probably better to use the various--- lenses for manipulation, as they echo the changes around the tree.-newtype ID = ID Int+-- $ids+-- The various ID types represent an identifier for a person, family, or event. +-- While the constructors are exported, it is probably better to use the+-- various lenses for manipulation, as they echo the changes around the tree+-- automatically.+newtype PersonID = PersonID Int +newtype FamilyID = FamilyID Int++newtype EventID = EventID Int+ -- | Constructs a lens for the manipulation of a person in a family tree, from -- that person's ID. Using an ID that does not correspond to a person is an -- error, and it is impossible to create or destroy people using a lens created -- by this. -personLens :: ID -> Lens FamilyTree Person-personLens (ID n) = lens ((IM.! n) . people) $+personLens :: PersonID -> Lens FamilyTree Person+personLens (PersonID n) = lens ((IM.! n) . people) $   \person familyTree ->     let oldPerson = people familyTree IM.! n         newattended = (IS.difference `on` attendedEvents)@@ -253,8 +266,8 @@ -- that family's ID. Using an ID that does not correspond to a family is an -- error, and it is impossible to create or destroy families using a lens -- created by this.       -familyLens :: ID -> Lens FamilyTree Family-familyLens (ID n) = lens ((IM.! n) . families) $+familyLens :: FamilyID -> Lens FamilyTree Family+familyLens (FamilyID n) = lens ((IM.! n) . families) $   \family' familyTree ->     familyTree       {families = IM.insert n family' (families familyTree)@@ -264,8 +277,8 @@ -- that event's ID. Using an ID that does not correspond to an event is an -- error, and it is impossible to create or destroy events using a lens created -- by this.       -eventLens :: ID -> Lens FamilyTree Event-eventLens (ID n) = lens ((IM.! n) . events) $+eventLens :: EventID -> Lens FamilyTree Event+eventLens (EventID n) = lens ((IM.! n) . events) $   \event familyTree ->     familyTree       {events = IM.insert n event (events familyTree)@@ -317,39 +330,39 @@  -- | Adds a person with minimal information, returning the updated family tree -- and the ID of the new person.  -addPerson :: FamilyTree -> (FamilyTree, ID)+addPerson :: FamilyTree -> (FamilyTree, PersonID) addPerson familyTree =   let n = maybe 0 fst $           listToMaybe $           dropWhile (uncurry (==)) $           zip [1 ..] $ IM.keys $ people familyTree   in (familyTree-       {people = IM.insert n blankPerson $ people familyTree}, ID n)+       {people = IM.insert n blankPerson $ people familyTree}, PersonID n)  -- | Adds a family with minimal information, returning the updated family tree -- and the ID of the new family.  -addFamily :: FamilyTree -> (FamilyTree, ID)+addFamily :: FamilyTree -> (FamilyTree, FamilyID) addFamily familyTree =   let n = maybe 0 fst $           listToMaybe $           dropWhile (uncurry (==)) $           zip [1 ..] $ IM.keys $ families familyTree   in (familyTree -       {families = IM.insert n blankFamily $ families familyTree}, ID n)+       {families = IM.insert n blankFamily $ families familyTree}, FamilyID n)  -- | Adds an event with minimal information, returning the updated family tree -- and the ID of the new event.-addEvent :: FamilyTree -> (FamilyTree, ID)+addEvent :: FamilyTree -> (FamilyTree, EventID) addEvent familyTree =   let n = maybe 0 fst $           listToMaybe $           dropWhile (uncurry (==)) $           zip [1 ..] $ IM.keys $ events familyTree-  in (familyTree {events = IM.insert n blankEvent $ events familyTree}, ID n)+  in (familyTree {events = IM.insert n blankEvent $ events familyTree}, EventID n)  -- | Deletes a person from the family tree, removing all references to them.  -deletePerson :: ID -> FamilyTree -> FamilyTree-deletePerson (ID n) familyTree =+deletePerson :: PersonID -> FamilyTree -> FamilyTree+deletePerson (PersonID n) familyTree =   familyTree      {people = IM.delete n $ people familyTree     ,families = IM.map@@ -368,14 +381,14 @@     }  -- | Deletes a family from the family tree, removing all references to it.    -deleteFamily :: ID -> FamilyTree -> FamilyTree-deleteFamily (ID n) familyTree =+deleteFamily :: FamilyID -> FamilyTree -> FamilyTree+deleteFamily (FamilyID n) familyTree =   familyTree     {families = IM.delete n $ families familyTree}  -- | Deletes an event from the family tree, removing all references to it.-deleteEvent :: ID -> FamilyTree -> FamilyTree-deleteEvent (ID n) familyTree =+deleteEvent :: EventID -> FamilyTree -> FamilyTree+deleteEvent (EventID n) familyTree =   let relevantPeople = eventAttendees (events familyTree IM.! n)   in familyTree        {events = IM.delete n $ events familyTree