-- | Break a device tree path into (first component, remaining)
bkPath :: DevicePath -> (Text,Text)
bkPath p = second f (Text.breakOn (Text.pack "/") p')
   where
      -- handle paths starting with "/"
      p' = if not (Text.null p) && Text.head p == '/'
               then Text.tail p
               else p
      f xs 
         | Text.null xs = xs
         | otherwise    = Text.tail xs

-- | Create a device tree
bkPath :: DevicePath -> (Text,Text)
bkPath p = second f (Text.breakOn (Text.pack "/") p')
   where
      -- handle paths starting with "/"
      p' = if not (Text.null p) && Text.head p == '/'
               then Text.tail p
               else p
      f xs 
         | Text.null xs = xs
         | otherwise    = Text.tail xs

-- | Create a device tree
bkPath p = second f (Text.breakOn (Text.pack "/") p')
   where
      -- handle paths starting with "/"
      p' = if not (Text.null p) && Text.head p == '/'
               then Text.tail p
               else p
      f xs 
         | Text.null xs = xs
         | otherwise    = Text.tail xs

-- | Create a device tree