git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #2370, allow rows in instance contexts
commit81a578f5484f0770ca0628c52176eb1ff0db93ee authorPhil Freeman <paf31@cantab.net> dateSat 8 Oct 2016, 12:39 (10 years ago) parent7523944
2 files changed+26−2
examples/passing/RowsInInstanceContext.purs+25 src/Language/PureScript/TypeChecker.hs+1−2
examples/passing/RowsInInstanceContext.pursnew file+25
@@ -0,0 +1,25 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff (Eff)
5+import Control.Monad.Eff.Console (CONSOLE, log)
6+import Data.Newtype (class Newtype, unwrap)
7+
8+class TypeEquals a b | a -> b, b -> a where
9+ coerce :: a -> b
10+ coerceBack :: b -> a
11+
12+instance refl :: TypeEquals a a where
13+ coerce = id
14+ coerceBack = id
15+
16+newtype RecordNewtype = RecordNewtype { x :: String }
17+
18+instance newtypeRecordNewtype ::
19+ TypeEquals inner { x :: String }
20+ => Newtype RecordNewtype inner where
21+ wrap = RecordNewtype <<< coerce
22+ unwrap (RecordNewtype rec) = coerceBack rec
23+
24+main :: Eff (console :: CONSOLE) Unit
25+main = log (unwrap (RecordNewtype { x: "Done" })).x
src/Language/PureScript/TypeChecker.hs+1−2
@@ -11,7 +11,7 @@ module Language.PureScript.TypeChecker
1111
1212import Prelude.Compat
1313
14−import Control.Monad (when, unless, void, forM, forM_)
14+import Control.Monad (when, unless, void, forM)
1515import Control.Monad.Error.Class (MonadError(..))
1616import Control.Monad.State.Class (MonadState(..), modify)
1717import Control.Monad.Supply.Class (MonadSupply)
@@ -279,7 +279,6 @@ typeCheckAll moduleName _ = traverse go
279279 return d
280280 go (d@(TypeInstanceDeclaration dictName deps className tys body)) = rethrow (addHint (ErrorInInstance className tys)) $ do
281281 traverse_ (checkTypeClassInstance moduleName) tys
282− forM_ deps $ traverse_ (checkTypeClassInstance moduleName) . constraintArgs
283282 checkOrphanInstance dictName className tys
284283 _ <- traverseTypeInstanceBody checkInstanceMembers body
285284 let dict = TypeClassDictionaryInScope (Qualified (Just moduleName) dictName) [] className tys (Just deps)