git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Relax restriction on data constructor names
commitbc8ce42bcaded38f04e878d4c623a84a8700354d authorGary Burgess <gary.burgess@gmail.com> dateTue 11 Feb 2014, 17:37 (13 years ago) parent3b2638d
4 files changed+8−9
examples/passing/Auto.purs+3−3 examples/passing/DataImport.purs+3−3 examples/passing/Person.purs+2−2 src/Language/PureScript/TypeChecker.hs−1
examples/passing/Auto.purs+3−3
@@ -1,14 +1,14 @@
11module Auto where
22
3− data Auto s i o = MkAuto { state :: s, step :: s -> i -> o }
3+ data Auto s i o = Auto { state :: s, step :: s -> i -> o }
44
55 type SomeAuto i o = forall r. (forall s. Auto s i o -> r) -> r
66
77 exists :: forall s i o. s -> (s -> i -> o) -> SomeAuto i o
8− exists = \state step f -> f (MkAuto { state: state, step: step })
8+ exists = \state step f -> f (Auto { state: state, step: step })
99
1010 run :: forall i o. SomeAuto i o -> i -> o
11− run = \s i -> s (\a -> case a of MkAuto a -> a.step a.state i)
11+ run = \s i -> s (\a -> case a of Auto a -> a.step a.state i)
1212
1313module Main where
1414
examples/passing/DataImport.purs+3−3
@@ -1,13 +1,13 @@
11module M1 where
22
3−data Test = MkTest String
3+data Test = Test String
44
55module Main where
66
77import M1
88
9−unTest (MkTest s) = s
9+unTest (Test s) = s
1010
1111main = do
12− let x = unTest (MkTest "Done")
12+ let x = unTest (Test "Done")
1313 Trace.trace x
examples/passing/Person.purs+2−2
@@ -2,13 +2,13 @@ module Person where
22
33 import Prelude ((++))
44
5− data Person = MkPerson { name :: String, age :: Number }
5+ data Person = Person { name :: String, age :: Number }
66
77 foreign import itoa :: Number -> String
88
99 showPerson :: Person -> String
1010 showPerson = \p -> case p of
11− MkPerson o -> o.name ++ ", aged " ++ itoa(o.age)
11+ Person o -> o.name ++ ", aged " ++ itoa(o.age)
1212
1313module Main where
1414
src/Language/PureScript/TypeChecker.hs−1
@@ -50,7 +50,6 @@ addDataConstructor :: ModuleName -> ProperName -> [String] -> ProperName -> [Typ
5050addDataConstructor moduleName name args dctor tys = do
5151 env <- getEnv
5252 dataConstructorIsNotDefined moduleName dctor
53− when (runModuleName moduleName == dctor) $ throwError "A data constructor may not have the same name as its enclosing module."
5453 let retTy = foldl TypeApp (TypeConstructor (Qualified (Just moduleName) name)) (map TypeVar args)
5554 let dctorTy = foldr function retTy tys
5655 let polyType = mkForAll args dctorTy