-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from haskell-works/newhoggy/update-ci
Update CI
- Loading branch information
Showing
7 changed files
with
55 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module HaskellWorks.Data.MQuery.Entry where | ||
|
||
import Text.PrettyPrint.ANSI.Leijen | ||
import Prettyprinter | ||
|
||
data Entry k v = Entry k v | ||
|
||
instance (Pretty k, Pretty v) => Pretty (Entry k v) where | ||
pretty (Entry k v) = pretty k <> text ": " <> pretty v | ||
pretty (Entry k v) = pretty k <> ": " <> pretty v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module HaskellWorks.Data.MQuery.Micro where | ||
|
||
import Text.PrettyPrint.ANSI.Leijen | ||
import Prettyprinter | ||
import Prettyprinter.Render.Text | ||
|
||
|
||
import qualified Data.DList as DL | ||
|
||
newtype Micro a = Micro a | ||
|
||
prettyVs :: Pretty a => [a] -> Doc | ||
prettyVs (kv:kvs) = pretty kv <> foldl (<>) empty ((\jv -> text ", " <> pretty jv) `map` kvs) | ||
prettyVs [] = empty | ||
prettyVs :: Pretty a => [a] -> Doc ann | ||
prettyVs (kv:kvs) = pretty kv <> foldl (<>) mempty ((\jv -> ", " <> pretty jv) `map` kvs) | ||
prettyVs [] = mempty | ||
|
||
putPretty :: Pretty a => a -> IO () | ||
putPretty a = putDoc (pretty a <> hardline) | ||
|
||
prettyKvs :: Pretty (Micro a) => [a] -> Doc | ||
prettyKvs (kv:kvs) = pretty (Micro kv) <> foldl (<>) empty ((\jv -> text ", " <> pretty (Micro jv)) `map` kvs) | ||
prettyKvs [] = empty | ||
prettyKvs :: Pretty (Micro a) => [a] -> Doc ann | ||
prettyKvs (kv:kvs) = pretty (Micro kv) <> foldl (<>) mempty ((\jv -> ", " <> pretty (Micro jv)) `map` kvs) | ||
prettyKvs [] = mempty | ||
|
||
instance Pretty a => Pretty (Micro [a]) where | ||
pretty (Micro xs) = case length xs of | ||
xsLen | xsLen == 0 -> text "[]" | ||
xsLen | xsLen <= 10 -> text "[" <> prettyVs xs <> text "]" | ||
_ -> text "[" <> prettyVs (take 10 xs) <> text ", ..]" | ||
xsLen | xsLen == 0 -> "[]" | ||
xsLen | xsLen <= 10 -> "[" <> prettyVs xs <> "]" | ||
_ -> "[" <> prettyVs (take 10 xs) <> ", ..]" | ||
|
||
instance Pretty a => Pretty (Micro (DL.DList a)) where | ||
pretty (Micro dxs) = case DL.toList dxs of | ||
xs@(_:_:_:_:_:_:_:_:_:_:_:_:_) -> text "[" <> prettyVs (take 50 xs) <> text ", ..]" | ||
[] -> text "[]" | ||
xs -> text "[" <> prettyVs xs <> text "]" | ||
xs@(_:_:_:_:_:_:_:_:_:_:_:_:_) -> "[" <> prettyVs (take 50 xs) <> ", ..]" | ||
[] -> "[]" | ||
xs -> "[" <> prettyVs xs <> "]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module HaskellWorks.Data.MQuery.Mini where | ||
|
||
import HaskellWorks.Data.MQuery.AtLeastSize | ||
import HaskellWorks.Data.MQuery.Micro | ||
import Text.PrettyPrint.ANSI.Leijen | ||
import Prettyprinter | ||
|
||
import qualified Data.DList as DL | ||
|
||
newtype Mini a = Mini a | ||
|
||
instance Pretty (Micro a) => Pretty (Mini [a]) where | ||
pretty (Mini xs) | xs `atLeastSize` 11 = text "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> text ", ..]" | ||
pretty (Mini xs) | xs `atLeastSize` 1 = text "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> text "]" | ||
pretty (Mini _ ) = text "[]" | ||
pretty (Mini xs) | xs `atLeastSize` 11 = "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> ", ..]" | ||
pretty (Mini xs) | xs `atLeastSize` 1 = "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> "]" | ||
pretty (Mini _ ) = "[]" | ||
|
||
instance Pretty (Mini a) => Pretty (Mini (DL.DList a)) where | ||
pretty (Mini xs) = vcat (punctuate (text ",") ((pretty . Mini) `map` take 10 (DL.toList xs))) | ||
pretty (Mini xs) = vcat (punctuate "," ((pretty . Mini) `map` take 10 (DL.toList xs))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters