在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):haskell/stylish-haskell开源软件地址(OpenSource Url):https://github.com/haskell/stylish-haskell开源编程语言(OpenSource Language):Haskell 98.4%开源软件介绍(OpenSource Introduction):stylish-haskellIntroductionA simple Haskell code prettifier. The goal is not to format all of the code in a file, since I find those kind of tools often "get in the way". However, manually cleaning up import statements etc. gets tedious very quickly. This tool tries to help where necessary without getting in the way. InstallationYou can install it using You can also install it using your package manager:
Features
Feature requests are welcome! Use the issue tracker for that. ExampleTurns: {-# LANGUAGE ViewPatterns, TemplateHaskell #-}
{-# LANGUAGE GeneralizedNewtypeDeriving,
ViewPatterns,
ScopedTypeVariables #-}
module Bad where
import Control.Applicative ((<$>))
import System.Directory (doesFileExist)
import qualified Data.Map as M
import Data.Map ((!), keys, Map)
data Point = Point { pointX, pointY :: Double , pointName :: String} deriving (Show) into: {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
module Bad where
import Control.Applicative ((<$>))
import System.Directory (doesFileExist)
import Data.Map (Map, keys, (!))
import qualified Data.Map as M
data Point = Point
{ pointX, pointY :: Double
, pointName :: String
} deriving (Show) ConfigurationThe tool is customizable to some extent. It tries to find a config file in the following order:
Use Record formattingBasically, stylish-haskell supports 4 different styles of records, controlled by Here's an example of all four styles: -- equals: "indent 2", "first_field": "indent 2"
data Foo a
= Foo
{ a :: Int
, a2 :: String
-- ^ some haddock
}
| Bar
{ b :: a
}
deriving (Eq, Show)
deriving (ToJSON) via Bar Foo
-- equals: "same_line", "first_field": "indent 2"
data Foo a = Foo
{ a :: Int
, a2 :: String
-- ^ some haddock
}
| Bar
{ b :: a
}
deriving (Eq, Show)
deriving (ToJSON) via Bar Foo
-- equals: "same_line", "first_field": "same_line"
data Foo a = Foo { a :: Int
, a2 :: String
-- ^ some haddock
}
| Bar { b :: a
}
deriving (Eq, Show)
deriving (ToJSON) via Bar Foo
-- equals: "indent 2", first_field: "same_line"
data Foo a
= Foo { a :: Int
, a2 :: String
-- ^ some haddock
}
| Bar { b :: a
}
deriving (Eq, Show)
deriving (ToJSON) via Bar Foo Editor integrationHaskell Language ServerHaskell Language Server(HLS) includes a plugin
for stylish-haskell. By changing the formatting provider option
( VIM integrationSince it works as a filter it is pretty easy to integrate this with VIM. You can call
and add a keybinding for it. Or you can define
and then use Alternatively, [vim-autoformat] supports stylish-haskell. To have it automatically reformat the files on save, add to your vimrc: autocmd BufWrite *.hs :Autoformat
" Don't automatically indent on save, since vim's autoindent for haskell is buggy
autocmd FileType haskell let b:autoformat_autoindent=0 There are also plugins that run stylish-haskell automatically when you save a Haskell file: Emacs integrationhaskell-mode for Emacs supports Atom integrationide-haskell for Atom supports atom-beautify for Atom supports Haskell using Visual Studio Code integrationstylish-haskell-vscode for VSCode supports Using with Continuous IntegrationYou can quickly grab the latest binary and run
Where the CreditsWritten and maintained by Jasper Van der Jeugt. Contributors:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论