Skip to content

Commit

Permalink
LabeledFamily: make remove member number if it is equal to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
WeissP committed Mar 19, 2024
1 parent 956044c commit a58fa04
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/WorkspaceFamily.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ allLabeledFamilies =
, ("", "y")
, ("", "n")
, ("", "-")
, (scratchpadWorkspaceTag, "0")
]

instance Family LabeledFamily where
fName (LabeledFamily name _) = name
fPrefix = fName
idWithMember f (FamilyMember 1) = fPrefix f
idWithMember f m = fPrefix f <> show m

instance Node LabeledFamily where
workspaceID = fullID
Expand All @@ -83,7 +86,6 @@ class Family a where
fName :: a -> FamilyName
fPrefix :: a -> String
idWithMember :: a -> FamilyMember -> WorkspaceId
idWithMember f = (fPrefix f <>) . show
hasWorkspace :: a -> WorkspaceId -> Bool
hasWorkspace f ws = fPrefix f `isPrefixOf` ws
fullID :: a -> X WorkspaceId
Expand All @@ -93,6 +95,7 @@ data GFamily = forall a. (Family a) => GFamily a
instance Family GFamily where
fName (GFamily f) = fName f
fPrefix (GFamily f) = fPrefix f
idWithMember (GFamily f) = idWithMember f

allFamilies :: [GFamily]
allFamilies = (allLabeledFamilies <&> GFamily) <> (allNumberedFamilies <&> GFamily)
Expand Down Expand Up @@ -198,9 +201,7 @@ swapElements n m (x : xs)
numToKey :: Int -> String
numToKey s = ["m", ",", ".", "j", "k", "l", "u", "i", "o", "-"] !! (s - 1)

myWorkspaces =
scratchpadWorkspaceTag
: [idWithMember f m | f <- allFamilies, m <- allFamilyMembers]
myWorkspaces = [idWithMember f m | f <- allFamilies, m <- allFamilyMembers]

logWorkspaceFamilies :: Logger
logWorkspaceFamilies = do
Expand Down

0 comments on commit a58fa04

Please sign in to comment.