Skip to content

Commit

Permalink
remove NonEmpty partial functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ear7h committed Jun 28, 2021
1 parent e352d8a commit 982f8a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dhall-toml/src/Dhall/Toml.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Toml.Type.Key (Piece(Piece), Key(Key, unKey))
import Toml.Type.Printer (pretty)

import qualified Data.Bifunctor as Bifunctor
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Sequence as Seq
import qualified Data.Text.IO as Text.IO
import qualified Dhall.Map as Map
Expand Down Expand Up @@ -70,7 +69,10 @@ toTomlTable r = foldM (toTomlRecordFold []) (mempty :: TOML) (Map.toList r)

toTomlRecordFold :: [Piece] -> TOML -> (Text, Core.RecordField Void Void) -> Either CompileError TOML
toTomlRecordFold curKey toml' (key', val) = toToml toml' newKey (Core.recordFieldValue val)
where newKey = Key $ NonEmpty.fromList $ curKey ++ [Piece key']
where
append [] y = y :| []
append (x:xs) y = x :| xs ++ [y]
newKey = Key $ append curKey $ Piece key'

-- | A helper function for dhallToToml. It recursively adds the values in
-- the Expr to the TOML. It has an invariant that key can be null iff
Expand Down

0 comments on commit 982f8a8

Please sign in to comment.