Skip to content

Commit fa63ace

Browse files
fmt
1 parent 5b6ccb3 commit fa63ace

File tree

11 files changed

+135
-140
lines changed

11 files changed

+135
-140
lines changed

libs/constrained-generators/src/Constrained/API.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ import Constrained.Generation
188188
import Constrained.Generic
189189
import Constrained.NumOrd
190190
import Constrained.Properties
191-
import Constrained.Spec.Map
192191
import Constrained.Spec.List
192+
import Constrained.Spec.Map
193193
import Constrained.Spec.Set
194194
import Constrained.Spec.SumProd
195195
import Constrained.Spec.Tree

libs/constrained-generators/src/Constrained/AbstractSyntax.hs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
{-# LANGUAGE UndecidableInstances #-}
1616

1717
-- | This module contains the abstract syntax of terms, predicates, and specifications
18-
module Constrained.AbstractSyntax
19-
( TermD (..)
20-
, runTermE
21-
, runTerm
22-
, fastInequality
23-
, PredD (..)
24-
, SpecificationD (..)
25-
, BinderD (..)
26-
, Weighted (..)
27-
, mapWeighted
28-
, traverseWeighted
29-
, AppRequiresD
30-
, Syntax(..)
31-
) where
18+
module Constrained.AbstractSyntax (
19+
TermD (..),
20+
runTermE,
21+
runTerm,
22+
fastInequality,
23+
PredD (..),
24+
SpecificationD (..),
25+
BinderD (..),
26+
Weighted (..),
27+
mapWeighted,
28+
traverseWeighted,
29+
AppRequiresD,
30+
Syntax (..),
31+
) where
3232

3333
import Constrained.Core
3434
import Constrained.DependencyInjection
@@ -52,10 +52,11 @@ import Test.QuickCheck
5252
------------------------------------------------------------------------
5353

5454
-- | First-order terms, application, literals, variables.
55-
--
55+
5656
-- $depsExplanation
5757
-- See `Constrained.DependencyInjection` to better understand @deps@ - it's a
5858
-- pointer to postpone having to define `HasSpec` and friends here.
59+
5960
data TermD deps a where
6061
App ::
6162
AppRequiresD deps t dom rng =>
@@ -171,8 +172,6 @@ instance Show a => Show (TermD deps a) where
171172
-- in to handle things like sum types and the specific problems you get into
172173
-- when generating from constraints (mostly to do with choosing the order in
173174
-- which to generate things).
174-
--
175-
-- $depsExplanation
176175
data PredD deps where
177176
ElemPred ::
178177
(HasSpecD deps a, Show a) =>
@@ -265,8 +264,6 @@ data PredD deps where
265264
Explain :: NE.NonEmpty String -> PredD deps -> PredD deps
266265

267266
-- | Binders, a `Var` is bound in a `Pred`, never anywhere else
268-
--
269-
-- $depsExplanation
270267
data BinderD deps a where
271268
(:->) ::
272269
(HasSpecD deps a, Show a) =>
@@ -346,8 +343,6 @@ instance Pretty (BinderD deps a) where
346343
------------------------------------------------------------------------
347344

348345
-- | A @`Specification` a@ denotes a set of @a@s
349-
--
350-
-- $depsExplanation
351346
data SpecificationD deps a where
352347
-- | Explain a Specification
353348
ExplainSpec :: [String] -> SpecificationD deps a -> SpecificationD deps a

libs/constrained-generators/src/Constrained/Core.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Constrained.Core (
1818
eqVar,
1919
Rename (..),
2020
freshen,
21+
2122
-- * Random cruft
2223
Value (..),
2324
unValue,

libs/constrained-generators/src/Constrained/PrettyUtils.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
{-# LANGUAGE TypeApplications #-}
1010

1111
-- | Utility functions for writing pretty-printers
12-
1312
module Constrained.PrettyUtils (
1413
-- * Precedence
15-
WithPrec(..),
14+
WithPrec (..),
1615
parensIf,
1716
prettyPrec,
17+
1818
-- * Lists
1919
ppList,
2020
ppListC,
21+
2122
-- * General helpers
2223
prettyType,
2324
vsep',
2425
(/>),
2526
showType,
2627
short,
27-
) where
28+
) where
2829

2930
import Constrained.List
3031
import Data.String (fromString)

libs/constrained-generators/src/Constrained/Spec/List.hs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
{-# LANGUAGE LambdaCase #-}
2-
{-# LANGUAGE TypeOperators #-}
31
{-# LANGUAGE AllowAmbiguousTypes #-}
2+
{-# LANGUAGE DataKinds #-}
3+
{-# LANGUAGE DefaultSignatures #-}
4+
{-# LANGUAGE ExistentialQuantification #-}
45
{-# LANGUAGE FlexibleContexts #-}
5-
{-# LANGUAGE UndecidableSuperClasses #-}
6+
{-# LANGUAGE FlexibleInstances #-}
67
{-# LANGUAGE FunctionalDependencies #-}
7-
{-# LANGUAGE TypeFamilies #-}
88
{-# LANGUAGE GADTs #-}
9-
{-# LANGUAGE FlexibleInstances #-}
10-
{-# LANGUAGE DefaultSignatures #-}
119
{-# LANGUAGE KindSignatures #-}
12-
{-# LANGUAGE TypeApplications #-}
10+
{-# LANGUAGE LambdaCase #-}
11+
{-# LANGUAGE OverloadedStrings #-}
12+
{-# LANGUAGE PatternSynonyms #-}
1313
{-# LANGUAGE ScopedTypeVariables #-}
1414
{-# LANGUAGE StandaloneDeriving #-}
15-
{-# LANGUAGE DataKinds #-}
15+
{-# LANGUAGE TypeApplications #-}
16+
{-# LANGUAGE TypeFamilies #-}
17+
{-# LANGUAGE TypeOperators #-}
18+
{-# LANGUAGE UndecidableSuperClasses #-}
1619
{-# LANGUAGE ViewPatterns #-}
17-
{-# LANGUAGE ExistentialQuantification #-}
18-
{-# LANGUAGE PatternSynonyms #-}
19-
{-# LANGUAGE OverloadedStrings #-}
2020
{-# OPTIONS_GHC -Wno-orphans #-}
2121

22-
module Constrained.Spec.List
23-
( ListSpec(..)
24-
, ListW(..)
25-
, ElemW(..)
26-
, pattern Elem
27-
, append_
28-
, singletonList_
29-
, elem_
30-
, sum_
31-
, foldMap_
32-
, Foldy(..)
33-
, FoldSpec(..)
34-
, preMapFoldSpec
35-
, toPredsFoldSpec
36-
, adds
37-
, conformsToFoldSpec
38-
, combineFoldSpec
39-
) where
22+
module Constrained.Spec.List (
23+
ListSpec (..),
24+
ListW (..),
25+
ElemW (..),
26+
pattern Elem,
27+
append_,
28+
singletonList_,
29+
elem_,
30+
sum_,
31+
foldMap_,
32+
Foldy (..),
33+
FoldSpec (..),
34+
preMapFoldSpec,
35+
toPredsFoldSpec,
36+
adds,
37+
conformsToFoldSpec,
38+
combineFoldSpec,
39+
) where
4040

41-
import Constrained.TheKnot
4241
import Constrained.AbstractSyntax
4342
import Constrained.Base
4443
import Constrained.Conformance
@@ -54,6 +53,7 @@ import Constrained.SumList
5453
-- TODO: some strange things here, why is SolverStage in here?!
5554
-- Because it is mutually recursive with something else in here.
5655
import Constrained.Syntax
56+
import Constrained.TheKnot
5757
import Control.Applicative
5858
import Control.Monad
5959
import Data.Foldable
@@ -135,7 +135,6 @@ guardListSpec msg l@(ListSpec _hint must size elemS _fold)
135135
)
136136
| otherwise = (typeSpec l)
137137

138-
139138
data ElemW :: [Type] -> Type -> Type where
140139
ElemW :: HasSpec a => ElemW '[a, [a]] Bool
141140

@@ -265,7 +264,6 @@ instance Forallable [a] a where
265264
fromForAllSpec es = typeSpec (ListSpec Nothing [] mempty es NoFold)
266265
forAllToList = id
267266

268-
269267
instance Logic ListW where
270268
propagateTypeSpec (FoldMapW f) (Unary HOLE) ts cant =
271269
typeSpec (ListSpec Nothing [] TrueSpec TrueSpec $ FoldSpec f (TypeSpec ts cant))
@@ -341,7 +339,6 @@ instance Logic ListW where
341339
unsafeExists $ \x' ->
342340
Assert (x ==. appFun (foldMapFn g) x') <> toPreds x' ts
343341

344-
345342
data ListW (args :: [Type]) (res :: Type) where
346343
FoldMapW :: forall a b. (Foldy b, HasSpec a) => Fun '[a] b -> ListW '[[a]] b
347344
SingletonListW :: HasSpec a => ListW '[a] [a]
@@ -624,4 +621,3 @@ instance Sized [a] where
624621
Just zs -> typeSpec (ListSpec Nothing mempty (MemberSpec zs) TrueSpec NoFold)
625622
sizeOfTypeSpec (ListSpec _ _ _ ErrorSpec {} _) = equalSpec 0
626623
sizeOfTypeSpec (ListSpec _ must sizespec _ _) = sizespec <> geqSpec (sizeOf must)
627-

libs/constrained-generators/src/Constrained/Spec/Map.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
{-# OPTIONS_GHC -Wno-orphans #-}
1616

1717
-- | `HasSpec` instance for `Map` and functions for working with `Map`s
18-
19-
module Constrained.Spec.Map
20-
( MapSpec (..)
21-
, defaultMapSpec
22-
, MapW (..)
23-
, lookup_
24-
, mapMember_
25-
, dom_
26-
, rng_
27-
) where
18+
module Constrained.Spec.Map (
19+
MapSpec (..),
20+
defaultMapSpec,
21+
MapW (..),
22+
lookup_,
23+
mapMember_,
24+
dom_,
25+
rng_,
26+
) where
2827

2928
import Constrained.AbstractSyntax
3029
import Constrained.Base

libs/constrained-generators/src/Constrained/Spec/Set.hs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515

1616
-- | `HasSpec` instance for `Set`s and functions for writing
1717
-- constraints about sets
18-
module Constrained.Spec.Set
19-
( SetSpec(..)
20-
, SetW(..)
21-
, singleton_
22-
, subset_
23-
, member_
24-
, union_
25-
, disjoint_
26-
, fromList_
27-
) where
18+
module Constrained.Spec.Set (
19+
SetSpec (..),
20+
SetW (..),
21+
singleton_,
22+
subset_,
23+
member_,
24+
union_,
25+
disjoint_,
26+
fromList_,
27+
) where
2828

2929
import Constrained.AbstractSyntax
3030
import Constrained.Base
@@ -36,11 +36,10 @@ import Constrained.Generation
3636
import Constrained.List
3737
import Constrained.NumOrd
3838
import Constrained.PrettyUtils
39-
import Constrained.SumList
4039
import Constrained.Spec.List
40+
import Constrained.SumList
4141
import Constrained.Syntax
4242
import Constrained.TheKnot
43-
4443
import Data.Foldable
4544
import Data.Kind
4645
import Data.List ((\\))
@@ -55,9 +54,14 @@ import Test.QuickCheck (shrinkList, shuffle)
5554
------------------------------------------------------------------------
5655

5756
-- | `TypeSpec` for `Set`
58-
data SetSpec a = SetSpec (Set a) -- ^ Required elements
59-
(Specification a) -- ^ Specification for elements
60-
(Specification Integer) -- ^ Specification for size
57+
data SetSpec a
58+
= SetSpec
59+
-- | Required elements
60+
(Set a)
61+
-- | Specification for elements
62+
(Specification a)
63+
-- | Specification for size
64+
(Specification Integer)
6165

6266
instance Ord a => Sized (Set.Set a) where
6367
sizeOf = toInteger . Set.size

libs/constrained-generators/src/Constrained/Spec/SumProd.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import Constrained.List (
9999
listShape,
100100
mapListC,
101101
)
102+
import Constrained.Spec.List
102103
import Constrained.Syntax (
103104
exists,
104105
forAll,
@@ -107,7 +108,6 @@ import Constrained.Syntax (
107108
reify,
108109
)
109110
import Constrained.TheKnot
110-
import Constrained.Spec.List
111111
import Constrained.TypeErrors
112112
import Data.Typeable (Typeable)
113113
import GHC.Generics

0 commit comments

Comments
 (0)