git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Relax restriction on data constructor names
bc8ce42Gary Burgess
examples/passing/Auto.purs+3−3
@@ -1,14 +1,14 @@
1module Auto where
1module Auto where
2
2
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 }
4
4
5 type SomeAuto i o = forall r. (forall s. Auto s i o -> r) -> r
5 type SomeAuto i o = forall r. (forall s. Auto s i o -> r) -> r
6
6
7 exists :: forall s i o. s -> (s -> i -> o) -> SomeAuto i o
7 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 })
9
9
10 run :: forall i o. SomeAuto i o -> i -> o
10 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)
12
12
13module Main where
13module Main where
14
14
examples/passing/DataImport.purs+3−3
@@ -1,13 +1,13 @@
1module M1 where
1module M1 where
2
2
3−data Test = MkTest String
3+data Test = Test String
4
4
5module Main where
5module Main where
6
6
7import M1
7import M1
8
8
9−unTest (MkTest s) = s
9+unTest (Test s) = s
10
10
11main = do
11main = do
12− let x = unTest (MkTest "Done")
12+ let x = unTest (Test "Done")
13 Trace.trace x
13 Trace.trace x
examples/passing/Person.purs+2−2
@@ -2,13 +2,13 @@ module Person where
2
2
3 import Prelude ((++))
3 import Prelude ((++))
4
4
5− data Person = MkPerson { name :: String, age :: Number }
5+ data Person = Person { name :: String, age :: Number }
6
6
7 foreign import itoa :: Number -> String
7 foreign import itoa :: Number -> String
8
8
9 showPerson :: Person -> String
9 showPerson :: Person -> String
10 showPerson = \p -> case p of
10 showPerson = \p -> case p of
11− MkPerson o -> o.name ++ ", aged " ++ itoa(o.age)
11+ Person o -> o.name ++ ", aged " ++ itoa(o.age)
12
12
13module Main where
13module Main where
14
14
src/Language/PureScript/TypeChecker.hs−1
@@ -50,7 +50,6 @@ addDataConstructor :: ModuleName -> ProperName -> [String] -> ProperName -> [Typ
50addDataConstructor moduleName name args dctor tys = do
50addDataConstructor moduleName name args dctor tys = do
51 env <- getEnv
51 env <- getEnv
52 dataConstructorIsNotDefined moduleName dctor
52 dataConstructorIsNotDefined moduleName dctor
53− when (runModuleName moduleName == dctor) $ throwError "A data constructor may not have the same name as its enclosing module."
54 let retTy = foldl TypeApp (TypeConstructor (Qualified (Just moduleName) name)) (map TypeVar args)
53 let retTy = foldl TypeApp (TypeConstructor (Qualified (Just moduleName) name)) (map TypeVar args)
55 let dctorTy = foldr function retTy tys
54 let dctorTy = foldr function retTy tys
56 let polyType = mkForAll args dctorTy
55 let polyType = mkForAll args dctorTy