Skip to content

Commit

Permalink
Minor style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
eskimor committed May 28, 2018
1 parent 6a2f808 commit a1c6c3c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
7 changes: 3 additions & 4 deletions src/Language/PureScript/Bridge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ writePSTypes :: FilePath -> FullBridge -> [SumType 'Haskell] -> IO ()
writePSTypes = writePSTypesWith Switches.defaultSwitch


-- | works like `writePSTypes` but you can add additional switches to control the generation of your PureScript code
-- | Works like `writePSTypes` but you can add additional switches to control the generation of your PureScript code
--
-- == Switches/Settings:
--
Expand All @@ -98,15 +98,14 @@ writePSTypesWith switch root bridge sts = do

where
settings = Switches.getSettings switch
bridged = map (bridgeSumType bridge) sts
bridged = map (bridgeSumType bridge) sts
modules = M.elems $ sumTypesToModules M.empty bridged
packages =
if Switches.generateLenses settings then
Set.insert "purescript-profunctor-lenses" $ sumTypesToNeededPackages bridged
else
sumTypesToNeededPackages bridged




-- | Translate all 'TypeInfo' values in a 'SumType' to PureScript types.
--
Expand Down
18 changes: 9 additions & 9 deletions src/Language/PureScript/Bridge/CodeGenSwitches.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- | general switches for the code generation, such as generating profunctor-lenses or not
-- | General switches for the code generation, such as generating profunctor-lenses or not
module Language.PureScript.Bridge.CodeGenSwitches
( Settings (..)
, defaultSettings
Expand All @@ -11,37 +11,37 @@ module Language.PureScript.Bridge.CodeGenSwitches

import Data.Monoid (Endo(..))

-- |general settings for code generation
-- | General settings for code generation
newtype Settings = Settings
{ generateLenses :: Bool -- ^use purescript-profunctor-lens for generated PS-types?
}
deriving (Eq, Show)


-- |Settings to generate Lenses
-- | Settings to generate Lenses
defaultSettings :: Settings
defaultSettings = Settings True


-- |you can `mappend` switches to control the code generation
-- | you can `mappend` switches to control the code generation
type Switch = Endo Settings


-- |translate switches into settings
-- | Translate switches into settings
getSettings :: Switch -> Settings
getSettings switch = appEndo switch defaultSettings


-- |default switches include code generation for lenses
-- | Default switches include code generation for lenses
defaultSwitch :: Switch
defaultSwitch = mempty


-- |switch off the generatation of profunctor-lenses
-- | Switch off the generatation of profunctor-lenses
noLenses :: Switch
noLenses = Endo $ \settings -> settings { generateLenses = False }


-- |switch on the generatation of profunctor-lenses
-- | Switch on the generatation of profunctor-lenses
genLenses :: Switch
genLenses = Endo $ \settings -> settings { generateLenses = True }
genLenses = Endo $ \settings -> settings { generateLenses = True }

0 comments on commit a1c6c3c

Please sign in to comment.