on master help sign in
move dupes function to MiscUtils
17802c0AgentM
ProjectM36/AtomType.hs+1−6
@@ -4,6 +4,7 @@ import ProjectM36.Base
4import qualified ProjectM36.TypeConstructorDef as TCD
4import qualified ProjectM36.TypeConstructorDef as TCD
5import qualified ProjectM36.TypeConstructor as TC
5import qualified ProjectM36.TypeConstructor as TC
6import qualified ProjectM36.DataConstructorDef as DCD
6import qualified ProjectM36.DataConstructorDef as DCD
7+import ProjectM36.MiscUtils
7import ProjectM36.Error
8import ProjectM36.Error
8import qualified ProjectM36.Attribute as A
9import qualified ProjectM36.Attribute as A
9import qualified Data.Vector as V
10import qualified Data.Vector as V
@@ -128,12 +129,6 @@ validateTypeConstructorDef tConsDef dConsList = execWriter $ do
128 mapM_ tell [map DataConstructorUsesUndeclaredTypeVariable (S.toList varsDiff)]
129 mapM_ tell [map DataConstructorUsesUndeclaredTypeVariable (S.toList varsDiff)]
129 pure ()
130 pure ()
130
131
131−--returns duplicates of a pre-sorted list
132−dupes :: Eq a => [a] -> [a]
133−dupes [] = []
134−dupes (_:[]) = []
135−dupes (x:y:[]) = if x == y then [x] else []
136−dupes (x:y:xs) = dupes(x:[y]) ++ dupes(xs)
137
132
138-- | Create an atom type iff all type variables are provided.
133-- | Create an atom type iff all type variables are provided.
139-- Either Int Text -> ConstructedAtomType "Either" {Int , Text}
134-- Either Int Text -> ConstructedAtomType "Either" {Int , Text}
ProjectM36/MiscUtils.hsnew file+8
@@ -0,0 +1,8 @@
1+module ProjectM36.MiscUtils where
2+
3+--returns duplicates of a pre-sorted list
4+dupes :: Eq a => [a] -> [a]
5+dupes [] = []
6+dupes (_:[]) = []
7+dupes (x:y:[]) = if x == y then [x] else []
8+dupes (x:y:xs) = dupes(x:[y]) ++ dupes(xs)