mirror of
https://github.com/aelve/guide.git
synced 2024-11-26 03:08:37 +03:00
commit
3b2d8b420a
@ -1,7 +1,4 @@
|
||||
{-# LANGUAGE
|
||||
OverloadedStrings
|
||||
#-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Config
|
||||
(
|
||||
@ -65,7 +62,7 @@ readConfig :: IO Config
|
||||
readConfig = do
|
||||
let filename = "config.json"
|
||||
exists <- doesFileExist filename
|
||||
when (not exists) $ do
|
||||
unless exists $ do
|
||||
putStrLn "config.json doesn't exist, creating it"
|
||||
BSL.writeFile filename (Aeson.encodePretty (def :: Config))
|
||||
contents <- BSL.fromStrict <$> BS.readFile filename
|
||||
|
13
lib/Guide.hs
13
lib/Guide.hs
@ -1,11 +1,8 @@
|
||||
{-# LANGUAGE
|
||||
OverloadedStrings,
|
||||
ScopedTypeVariables,
|
||||
TypeFamilies,
|
||||
DataKinds,
|
||||
FlexibleContexts
|
||||
#-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
|
||||
module Guide
|
||||
(
|
||||
|
@ -1,6 +1,4 @@
|
||||
{-# LANGUAGE
|
||||
NoImplicitPrelude
|
||||
#-}
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
|
||||
|
||||
-- | Imports used in the whole codebase.
|
||||
|
13
lib/JS.hs
13
lib/JS.hs
@ -1,11 +1,8 @@
|
||||
{-# LANGUAGE
|
||||
FlexibleInstances,
|
||||
GeneralizedNewtypeDeriving,
|
||||
OverloadedStrings,
|
||||
QuasiQuotes,
|
||||
BangPatterns
|
||||
#-}
|
||||
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
|
||||
-- TODO: try to make it more type-safe somehow?
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
{-# LANGUAGE
|
||||
OverloadedStrings,
|
||||
FlexibleInstances,
|
||||
FlexibleContexts
|
||||
#-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
|
||||
module Markdown
|
||||
(
|
||||
|
@ -1,6 +1,4 @@
|
||||
{-# LANGUAGE
|
||||
OverloadedStrings
|
||||
#-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
|
||||
module Merge
|
||||
@ -33,7 +31,7 @@ merge orig a b = T.concat . V.toList $ PV.apply (pa <> pb') orig'
|
||||
V.fromList . consolidate . map T.toStrict . break' . T.toString
|
||||
pa = PV.diff orig' a'
|
||||
pb = PV.diff orig' b'
|
||||
(_, pb') = PV.transformWith PV.ours pa pb
|
||||
(_, pb') = PV.transformWith PV.ours pa pb
|
||||
|
||||
-- | Break a string into words, spaces, and special characters.
|
||||
break' :: String -> [String]
|
||||
|
@ -1,6 +1,4 @@
|
||||
{-# LANGUAGE
|
||||
CPP
|
||||
#-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
|
||||
-- Hack for bug in older Cabal versions
|
||||
@ -38,7 +36,7 @@ internalDeriveSafeCopySorted versionId kindName tyName = do
|
||||
internalDeriveSafeCopySorted' versionId kindName tyName info
|
||||
|
||||
internalDeriveSafeCopySorted' :: Version a -> Name -> Name -> Info -> Q [Dec]
|
||||
internalDeriveSafeCopySorted' versionId kindName tyName info = do
|
||||
internalDeriveSafeCopySorted' versionId kindName tyName info =
|
||||
case info of
|
||||
#if MIN_VERSION_template_haskell(2,11,0)
|
||||
TyConI (DataD context _name tyvars _kind cons _derivs)
|
||||
|
14
lib/Types.hs
14
lib/Types.hs
@ -1,10 +1,8 @@
|
||||
{-# LANGUAGE
|
||||
QuasiQuotes,
|
||||
FlexibleContexts,
|
||||
FlexibleInstances,
|
||||
TypeFamilies,
|
||||
OverloadedStrings
|
||||
#-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
@ -926,7 +924,7 @@ setItemGroup itemId newGroup = do
|
||||
-- is moved to a different group. Note that this is done after adding a new
|
||||
-- group because we also want the color to change. So, if the item was the
|
||||
-- only item in its group, the sequence of actions is as follows:
|
||||
--
|
||||
--
|
||||
-- * new group is added (and hence a new color is assigned)
|
||||
-- * old group is deleted (and now the old color is unused)
|
||||
oldGroup <- use (itemLens.group_)
|
||||
|
30
lib/Utils.hs
30
lib/Utils.hs
@ -1,12 +1,10 @@
|
||||
{-# LANGUAGE
|
||||
ScopedTypeVariables,
|
||||
QuasiQuotes,
|
||||
OverloadedStrings,
|
||||
GeneralizedNewtypeDeriving,
|
||||
FlexibleContexts,
|
||||
FlexibleInstances,
|
||||
TypeFamilies
|
||||
#-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
@ -31,7 +29,7 @@ module Utils
|
||||
|
||||
-- * IP
|
||||
sockAddrToIP,
|
||||
|
||||
|
||||
-- * UID
|
||||
Uid(..),
|
||||
Node,
|
||||
@ -107,12 +105,12 @@ import Data.Generics.Uniplate.Data (transform)
|
||||
|
||||
-- | Move the -1st element that satisfies the predicate- up.
|
||||
moveUp :: (a -> Bool) -> [a] -> [a]
|
||||
moveUp p (x:y:xs) = if p y then (y:x:xs) else x : moveUp p (y:xs)
|
||||
moveUp p (x:y:xs) = if p y then y : x : xs else x : moveUp p (y:xs)
|
||||
moveUp _ xs = xs
|
||||
|
||||
-- | Move the -1st element that satisfies the predicate- down.
|
||||
moveDown :: (a -> Bool) -> [a] -> [a]
|
||||
moveDown p (x:y:xs) = if p x then (y:x:xs) else x : moveDown p (y:xs)
|
||||
moveDown p (x:y:xs) = if p x then y : x : xs else x : moveDown p (y:xs)
|
||||
moveDown _ xs = xs
|
||||
|
||||
deleteFirst :: (a -> Bool) -> [a] -> [a]
|
||||
@ -379,11 +377,11 @@ changelog bareTyName (newVer, Past oldVer) changes = do
|
||||
_ -> fail "changelog: the type must be a record"
|
||||
-- Check that all 'Added' fields are actually present in the new type
|
||||
-- and that all 'Removed' fields aren't there
|
||||
for_ (M.keys added) $ \n -> do
|
||||
for_ (M.keys added) $ \n ->
|
||||
unless (n `elem` map fst fields) $ fail $
|
||||
printf "changelog: field %s isn't present in %s"
|
||||
(show (mkNew n)) (show newTyName)
|
||||
for_ (M.keys removed) $ \n -> do
|
||||
for_ (M.keys removed) $ \n ->
|
||||
when (n `elem` map fst fields) $ fail $
|
||||
printf "changelog: field %s is present in %s \
|
||||
\but was supposed to be removed"
|
||||
@ -484,7 +482,7 @@ genVer tyName ver constructors = do
|
||||
(bangType bangNotStrict (conT fType))
|
||||
| (fName, fType) <- fields]
|
||||
|
||||
cons' <- for constructors $ \genCons -> do
|
||||
cons' <- for constructors $ \genCons ->
|
||||
case genCons of
|
||||
Copy conName -> copyConstructor conName
|
||||
Custom conName fields -> customConstructor conName fields
|
||||
@ -539,7 +537,7 @@ migrateVer tyName ver constructors = do
|
||||
(normalB res)
|
||||
[]
|
||||
|
||||
branches' <- for constructors $ \genCons -> do
|
||||
branches' <- for constructors $ \genCons ->
|
||||
case genCons of
|
||||
CopyM conName -> copyConstructor conName
|
||||
CustomM conName res -> customConstructor conName res
|
||||
|
13
lib/View.hs
13
lib/View.hs
@ -1,9 +1,6 @@
|
||||
{-# LANGUAGE
|
||||
QuasiQuotes,
|
||||
OverloadedStrings,
|
||||
FlexibleContexts
|
||||
#-}
|
||||
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
|
||||
module View
|
||||
(
|
||||
@ -1251,7 +1248,7 @@ markdownEditor attr (view mdText -> s) submit cancel instr = do
|
||||
cancel
|
||||
emptySpan "6px"
|
||||
span_ [class_ "edit-field-instruction"] (toHtml instr)
|
||||
a_ [href_ "/markdown", target_ "_blank"] $
|
||||
a_ [href_ "/markdown", target_ "_blank"] $
|
||||
img_ [src_ "/markdown.svg", alt_ "markdown supported", class_ " markdown-supported "]
|
||||
|
||||
smallMarkdownEditor
|
||||
@ -1277,7 +1274,7 @@ smallMarkdownEditor attr (view mdText -> s) submit mbCancel instr = do
|
||||
cancel
|
||||
span_ [style_ "float:right"] $ do
|
||||
span_ [class_ "edit-field-instruction"] (toHtml instr)
|
||||
a_ [href_ "/markdown", target_ "_blank"] $
|
||||
a_ [href_ "/markdown", target_ "_blank"] $
|
||||
img_ [src_ "/markdown.svg", alt_ "markdown supported", class_ " markdown-supported "]
|
||||
|
||||
thisNode :: MonadIO m => HtmlT m JQuerySelector
|
||||
|
Loading…
Reference in New Issue
Block a user