1
- {-# LANGUAGE NoImplicitPrelude #-}
2
- {-# LANGUAGE ConstraintKinds #-}
3
- {-# LANGUAGE DeriveDataTypeable #-}
4
- {-# LANGUAGE FlexibleContexts #-}
5
- {-# LANGUAGE OverloadedStrings #-}
6
- {-# LANGUAGE ScopedTypeVariables #-}
1
+ {-# LANGUAGE NoImplicitPrelude #-}
2
+ {-# LANGUAGE ConstraintKinds #-}
3
+ {-# LANGUAGE DeriveDataTypeable #-}
4
+ {-# LANGUAGE ExistentialQuantification #-}
5
+ {-# LANGUAGE FlexibleContexts #-}
6
+ {-# LANGUAGE OverloadedStrings #-}
7
+ {-# LANGUAGE ScopedTypeVariables #-}
8
+ {-# LANGUAGE StandaloneDeriving #-}
7
9
8
10
-- | Create new a new project directory populated with a basic working
9
11
-- project.
@@ -59,14 +61,16 @@ import Text.ProjectTemplate
59
61
data NewPrettyException
60
62
= ProjectDirAlreadyExists ! String ! (Path Abs Dir )
61
63
| DownloadTemplateFailed ! Text ! String ! VerifiedDownloadException
62
- | LoadTemplateFailed ! TemplateName ! FilePath
63
- | ExtractTemplateFailed ! TemplateName ! FilePath ! String
64
+ | forall b . LoadTemplateFailed ! TemplateName ! ( Path b File )
65
+ | forall b . ExtractTemplateFailed ! TemplateName ! ( Path b File ) ! String
64
66
| TemplateInvalid ! TemplateName ! StyleDoc
65
67
| MagicPackageNameInvalid ! String
66
68
| AttemptedOverwrites ! Text ! [Path Abs File ]
67
69
| DownloadTemplatesHelpFailed ! HttpException
68
70
| TemplatesHelpEncodingInvalid ! String ! UnicodeException
69
- deriving (Show , Typeable )
71
+ deriving Typeable
72
+
73
+ deriving instance Show NewPrettyException
70
74
71
75
instance Pretty NewPrettyException where
72
76
pretty (ProjectDirAlreadyExists name path) =
@@ -133,7 +137,7 @@ instance Pretty NewPrettyException where
133
137
[ flow " Stack failed to load the downloaded template"
134
138
, style Current (fromString $ T. unpack $ templateName name)
135
139
, " from"
136
- , style File (fromString path) <> " ."
140
+ , style File (pretty path) <> " ."
137
141
]
138
142
pretty (ExtractTemplateFailed name path err) =
139
143
" [S-9582]"
@@ -142,7 +146,7 @@ instance Pretty NewPrettyException where
142
146
[ flow " Stack failed to extract the loaded template"
143
147
, style Current (fromString $ T. unpack $ templateName name)
144
148
, " at"
145
- , style File (fromString path) <> " ."
149
+ , style File (pretty path) <> " ."
146
150
]
147
151
<> blankLine
148
152
<> flow " While extracting, Stack encountered the following exception:"
@@ -346,11 +350,11 @@ loadTemplate name logIt = do
346
350
bs <- readFileBinary (toFilePath path) -- readFileUtf8 (toFilePath path)
347
351
case extract bs of
348
352
Left err -> throwM $ PrettyException $
349
- ExtractTemplateFailed name (toFilePath path) err
353
+ ExtractTemplateFailed name path err
350
354
Right template ->
351
355
pure template
352
356
else throwM $ PrettyException $
353
- LoadTemplateFailed name (toFilePath path)
357
+ LoadTemplateFailed name path
354
358
relSettings :: String -> Maybe TemplateDownloadSettings
355
359
relSettings req = do
356
360
rtp <- parseRepoPathWithService defaultRepoService (T. pack req)
0 commit comments