on master help sign in
move dupes function to MiscUtils
commit17802c06e76c21a745896f448c965f8358267c76 authorAgentM <agentm@themactionfaction.com> dateSun 3 Apr 2016, 12:16 (11 years ago) parent13209bc
2 files changed+9−6
ProjectM36/AtomType.hs+1−6 ProjectM36/MiscUtils.hs+8
ProjectM36/AtomType.hs+1−6
@@ -4,6 +4,7 @@ import ProjectM36.Base
44import qualified ProjectM36.TypeConstructorDef as TCD
55import qualified ProjectM36.TypeConstructor as TC
66import qualified ProjectM36.DataConstructorDef as DCD
7+import ProjectM36.MiscUtils
78import ProjectM36.Error
89import qualified ProjectM36.Attribute as A
910import qualified Data.Vector as V
@@ -128,12 +129,6 @@ validateTypeConstructorDef tConsDef dConsList = execWriter $ do
128129 mapM_ tell [map DataConstructorUsesUndeclaredTypeVariable (S.toList varsDiff)]
129130 pure ()
130131
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)
137132
138133-- | Create an atom type iff all type variables are provided.
139134-- 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)