- | Take a qualified name and return only its last name. E.g. idName "main.Module.A" = "A"
idName :: Id -> String
idName id = let 
  name = drop (lastDotIndex id + 1) id -- name with a possible parenthesis at the end  
  in case name of 
    [] -> id
    ":" -> "(:)"    
    _ -> if (last name == ')')
         then init name
         else name
  where
    isDot = ((==) '.')
    dotIndexes = findIndices isDot
    lastDotIndex s = 
      case dotIndexes s of
        [] -> 0
        idxs -> last idxs
--    last . dotIndexes

idName :: Id -> String
idName id = let 
  name = drop (lastDotIndex id + 1) id -- name with a possible parenthesis at the end  
  in case name of 
    [] -> id
    ":" -> "(:)"    
    _ -> if (last name == ')')
         then init name
         else name
  where
    isDot = ((==) '.')
    dotIndexes = findIndices isDot
    lastDotIndex s = 
      case dotIndexes s of
        [] -> 0
        idxs -> last idxs
--    last . dotIndexes
idName id = let 
  name = drop (lastDotIndex id + 1) id -- name with a possible parenthesis at the end  
  in case name of 
    [] -> id
    ":" -> "(:)"    
    _ -> if (last name == ')')
         then init name
         else name
  where
    isDot = ((==) '.')
    dotIndexes = findIndices isDot
    lastDotIndex s = 
      case dotIndexes s of
        [] -> 0
        idxs -> last idxs
--    last . dotIndexes