Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb3ce33

Browse files
piq9117Gitea
piq9117
authored and
Gitea
committed
Generate Src directory (#1)
- implement parsers - implement application monad - implement ManageCommand typeclass - added stylish-haskell file - created mkMessage utility function - created mkPatName utility function
1 parent 68badb3 commit cb3ce33

File tree

13 files changed

+465
-6
lines changed

13 files changed

+465
-6
lines changed

‎.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
dist
2+
dist-*
3+
cabal-dev
4+
*.o
5+
*.hi
6+
*.hie
7+
*.chi
8+
*.chs.h
9+
*.dyn_o
10+
*.dyn_hi
11+
.hpc
12+
.hsenv
13+
.cabal-sandbox/
14+
cabal.sandbox.config
15+
*.prof
16+
*.aux
17+
*.hp
18+
*.eventlog
19+
.stack-work/
20+
cabal.project.local
21+
cabal.project.local~
22+
.HTF/
23+
.ghc.environment.*
24+
example/

‎.stylish-haskell.yaml

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
# stylish-haskell configuration file
2+
# ==================================
3+
4+
# The stylish-haskell tool is mainly configured by specifying steps. These steps
5+
# are a list, so they have an order, and one specific step may appear more than
6+
# once (if needed). Each file is processed by these steps in the given order.
7+
steps:
8+
# Convert some ASCII sequences to their Unicode equivalents. This is disabled
9+
# by default.
10+
# - unicode_syntax:
11+
# # In order to make this work, we also need to insert the UnicodeSyntax
12+
# # language pragma. If this flag is set to true, we insert it when it's
13+
# # not already present. You may want to disable it if you configure
14+
# # language extensions using some other method than pragmas. Default:
15+
# # true.
16+
# add_language_pragma: true
17+
18+
# Format record definitions. This is disabled by default.
19+
#
20+
# You can control the layout of record fields. The only rules that can't be configured
21+
# are these:
22+
#
23+
# - "|" is always aligned with "="
24+
# - "," in fields is always aligned with "{"
25+
# - "}" is likewise always aligned with "{"
26+
#
27+
# - records:
28+
# # How to format equals sign between type constructor and data constructor.
29+
# # Possible values:
30+
# # - "same_line" -- leave "=" AND data constructor on the same line as the type constructor.
31+
# # - "indent N" -- insert a new line and N spaces from the beginning of the next line.
32+
# equals: "indent 2"
33+
#
34+
# # How to format first field of each record constructor.
35+
# # Possible values:
36+
# # - "same_line" -- "{" and first field goes on the same line as the data constructor.
37+
# # - "indent N" -- insert a new line and N spaces from the beginning of the data constructor
38+
# first_field: "indent 2"
39+
#
40+
# # How many spaces to insert between the column with "," and the beginning of the comment in the next line.
41+
# field_comment: 2
42+
#
43+
# # How many spaces to insert before "deriving" clause. Deriving clauses are always on separate lines.
44+
# deriving: 2
45+
46+
# Align the right hand side of some elements. This is quite conservative
47+
# and only applies to statements where each element occupies a single
48+
# line. All default to true.
49+
- simple_align:
50+
cases: true
51+
top_level_patterns: true
52+
records: true
53+
54+
# Import cleanup
55+
- imports:
56+
# There are different ways we can align names and lists.
57+
#
58+
# - global: Align the import names and import list throughout the entire
59+
# file.
60+
#
61+
# - file: Like global, but don't add padding when there are no qualified
62+
# imports in the file.
63+
#
64+
# - group: Only align the imports per group (a group is formed by adjacent
65+
# import lines).
66+
#
67+
# - none: Do not perform any alignment.
68+
#
69+
# Default: global.
70+
align: global
71+
72+
# The following options affect only import list alignment.
73+
#
74+
# List align has following options:
75+
#
76+
# - after_alias: Import list is aligned with end of import including
77+
# 'as' and 'hiding' keywords.
78+
#
79+
# > import qualified Data.List as List (concat, foldl, foldr, head,
80+
# > init, last, length)
81+
#
82+
# - with_alias: Import list is aligned with start of alias or hiding.
83+
#
84+
# > import qualified Data.List as List (concat, foldl, foldr, head,
85+
# > init, last, length)
86+
#
87+
# - with_module_name: Import list is aligned `list_padding` spaces after
88+
# the module name.
89+
#
90+
# > import qualified Data.List as List (concat, foldl, foldr, head,
91+
# init, last, length)
92+
#
93+
# This is mainly intended for use with `pad_module_names: false`.
94+
#
95+
# > import qualified Data.List as List (concat, foldl, foldr, head,
96+
# init, last, length, scanl, scanr, take, drop,
97+
# sort, nub)
98+
#
99+
# - new_line: Import list starts always on new line.
100+
#
101+
# > import qualified Data.List as List
102+
# > (concat, foldl, foldr, head, init, last, length)
103+
#
104+
# Default: after_alias
105+
list_align: after_alias
106+
107+
# Right-pad the module names to align imports in a group:
108+
#
109+
# - true: a little more readable
110+
#
111+
# > import qualified Data.List as List (concat, foldl, foldr,
112+
# > init, last, length)
113+
# > import qualified Data.List.Extra as List (concat, foldl, foldr,
114+
# > init, last, length)
115+
#
116+
# - false: diff-safe
117+
#
118+
# > import qualified Data.List as List (concat, foldl, foldr, init,
119+
# > last, length)
120+
# > import qualified Data.List.Extra as List (concat, foldl, foldr,
121+
# > init, last, length)
122+
#
123+
# Default: true
124+
pad_module_names: true
125+
126+
# Long list align style takes effect when import is too long. This is
127+
# determined by 'columns' setting.
128+
#
129+
# - inline: This option will put as much specs on same line as possible.
130+
#
131+
# - new_line: Import list will start on new line.
132+
#
133+
# - new_line_multiline: Import list will start on new line when it's
134+
# short enough to fit to single line. Otherwise it'll be multiline.
135+
#
136+
# - multiline: One line per import list entry.
137+
# Type with constructor list acts like single import.
138+
#
139+
# > import qualified Data.Map as M
140+
# > ( empty
141+
# > , singleton
142+
# > , ...
143+
# > , delete
144+
# > )
145+
#
146+
# Default: inline
147+
long_list_align: inline
148+
149+
# Align empty list (importing instances)
150+
#
151+
# Empty list align has following options
152+
#
153+
# - inherit: inherit list_align setting
154+
#
155+
# - right_after: () is right after the module name:
156+
#
157+
# > import Vector.Instances ()
158+
#
159+
# Default: inherit
160+
empty_list_align: inherit
161+
162+
# List padding determines indentation of import list on lines after import.
163+
# This option affects 'long_list_align'.
164+
#
165+
# - <integer>: constant value
166+
#
167+
# - module_name: align under start of module name.
168+
# Useful for 'file' and 'group' align settings.
169+
#
170+
# Default: 4
171+
list_padding: 4
172+
173+
# Separate lists option affects formatting of import list for type
174+
# or class. The only difference is single space between type and list
175+
# of constructors, selectors and class functions.
176+
#
177+
# - true: There is single space between Foldable type and list of it's
178+
# functions.
179+
#
180+
# > import Data.Foldable (Foldable (fold, foldl, foldMap))
181+
#
182+
# - false: There is no space between Foldable type and list of it's
183+
# functions.
184+
#
185+
# > import Data.Foldable (Foldable(fold, foldl, foldMap))
186+
#
187+
# Default: true
188+
separate_lists: true
189+
190+
# Space surround option affects formatting of import lists on a single
191+
# line. The only difference is single space after the initial
192+
# parenthesis and a single space before the terminal parenthesis.
193+
#
194+
# - true: There is single space associated with the enclosing
195+
# parenthesis.
196+
#
197+
# > import Data.Foo ( foo )
198+
#
199+
# - false: There is no space associated with the enclosing parenthesis
200+
#
201+
# > import Data.Foo (foo)
202+
#
203+
# Default: false
204+
space_surround: false
205+
206+
# Language pragmas
207+
- language_pragmas:
208+
# We can generate different styles of language pragma lists.
209+
#
210+
# - vertical: Vertical-spaced language pragmas, one per line.
211+
#
212+
# - compact: A more compact style.
213+
#
214+
# - compact_line: Similar to compact, but wrap each line with
215+
# `{-#LANGUAGE #-}'.
216+
#
217+
# Default: vertical.
218+
style: vertical
219+
220+
# Align affects alignment of closing pragma brackets.
221+
#
222+
# - true: Brackets are aligned in same column.
223+
#
224+
# - false: Brackets are not aligned together. There is only one space
225+
# between actual import and closing bracket.
226+
#
227+
# Default: true
228+
align: true
229+
230+
# stylish-haskell can detect redundancy of some language pragmas. If this
231+
# is set to true, it will remove those redundant pragmas. Default: true.
232+
remove_redundant: true
233+
234+
# Language prefix to be used for pragma declaration, this allows you to
235+
# use other options non case-sensitive like "language" or "Language".
236+
# If a non correct String is provided, it will default to: LANGUAGE.
237+
language_prefix: LANGUAGE
238+
239+
# Replace tabs by spaces. This is disabled by default.
240+
# - tabs:
241+
# # Number of spaces to use for each tab. Default: 8, as specified by the
242+
# # Haskell report.
243+
# spaces: 8
244+
245+
# Remove trailing whitespace
246+
- trailing_whitespace: {}
247+
248+
# Squash multiple spaces between the left and right hand sides of some
249+
# elements into single spaces. Basically, this undoes the effect of
250+
# simple_align but is a bit less conservative.
251+
# - squash: {}
252+
253+
# A common setting is the number of columns (parts of) code will be wrapped
254+
# to. Different steps take this into account.
255+
#
256+
# Set this to null to disable all line wrapping.
257+
#
258+
# Default: 80.
259+
columns: 80
260+
261+
# By default, line endings are converted according to the OS. You can override
262+
# preferred format here.
263+
#
264+
# - native: Native newline format. CRLF on Windows, LF on other OSes.
265+
#
266+
# - lf: Convert to LF ("\n").
267+
#
268+
# - crlf: Convert to CRLF ("\r\n").
269+
#
270+
# Default: native.
271+
newline: native
272+
273+
# Sometimes, language extensions are specified in a cabal file or from the
274+
# command line instead of using language pragmas in the file. stylish-haskell
275+
# needs to be aware of these, so it can parse the file correctly.
276+
#
277+
# No language extensions are enabled by default.
278+
# language_extensions:
279+
# - TemplateHaskell
280+
# - QuasiQuotes
281+
282+
# Attempt to find the cabal file in ancestors of the current directory, and
283+
# parse options (currently only language extensions) from that.
284+
#
285+
# Default: true
286+
cabal: true

‎Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build:
2+
cabal new-build

‎app/Main.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module Main where
22

3+
import ClassyPrelude
4+
import UmuReactBasic
5+
36
main :: IO ()
4-
main = putStrLn"Hello, Haskell!"
7+
main = startApp

‎shell.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ let
55
inherit (nixpkgs) pkgs;
66

77
f = { mkDerivation, ansi-terminal, base, bytestring
8-
, classy-prelude, errors, mtl, optparse-applicative,stdenv,text
9-
, transformers, turtle
8+
, classy-prelude, errors, file-embed,mtl, optparse-applicative
9+
, stdenv,template-haskell,text,transformers, turtle
1010
}:
1111
mkDerivation {
1212
pname = "umu-react-basic";
@@ -15,8 +15,8 @@ let
1515
isLibrary = true;
1616
isExecutable = true;
1717
libraryHaskellDepends = [
18-
ansi-terminal base bytestring classy-prelude errors mtl
19-
optparse-applicative text transformers turtle
18+
ansi-terminal base bytestring classy-prelude errors file-embedmtl
19+
optparse-applicative template-haskelltext transformers turtle
2020
];
2121
executableHaskellDepends = [ base classy-prelude ];
2222
license = "unknown";

‎src/Import.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Import
2+
( module X
3+
, appName
4+
) where
5+
6+
import ClassyPrelude as X
7+
8+
appName :: Text
9+
appName = "umu-react-basic"

‎src/UmuReactBasic.hs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
2+
module UmuReactBasic where
3+
4+
import Import
5+
import Options.Applicative
6+
import UmuReactBasic.Capability.ManageCommand
7+
import UmuReactBasic.Parser
8+
9+
newtype AppM m a
10+
= AppM
11+
{ unAppM :: m a
12+
} deriving ( Functor, Applicative, Monad, MonadIO )
13+
14+
startApp :: IO ()
15+
startApp = do
16+
comm <- showHelpOnErrorExecParser
17+
( info ( helper <*> parseVersion <*> parseCommand )
18+
( fullDesc <> progDesc umuProgDesc <> header umuHeader ))
19+
runAppM $ run comm
20+
where
21+
run :: MonadIO m => ManageCommand m => Command -> AppM m ()
22+
run comm = case comm of
23+
CommandInit mLoc -> do
24+
generateProject mLoc
25+
26+
instance MonadIO m => ManageCommand ( AppM m ) where
27+
generateProject = generateProj
28+
29+
runAppM :: MonadIO m => AppM m a -> m a
30+
runAppM app = unAppM app
31+
32+
umuProgDesc :: String
33+
umuProgDesc = "Use umu-react-basic to generate a scaffold "
34+
<> "for a react-basic-hooks project"
35+
36+
umuHeader :: String
37+
umuHeader = "umu-react-basic: Generate react-basic-hooks Project"
38+
39+
showHelpOnErrorExecParser :: ParserInfo a -> IO a
40+
showHelpOnErrorExecParser = customExecParser ( prefs showHelpOnError )

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /