Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test case for ConstrainedTypeUnified
  • Loading branch information
purefunctor committed Aug 21, 2022
commit 344ebbe857ac2b6106e3f43d2b4200c8b9719120
11 changes: 11 additions & 0 deletions CHANGELOG.d/fix_polymorhic_constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@
{ a :: Maybe a1
}
```

Also as a consequence, record updates should not throw
`ConstrainedTypeUnified` in cases such as:

```purs
v1 :: { a :: Maybe Unit }
v1 = { a : Just Unit }

v2 :: { a :: Maybe Unit }
v2 = let v3 = v1 { a = mempty } in v3
```
11 changes: 9 additions & 2 deletions tests/purs/passing/4376.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Main where
import Prelude
import Prim.Row (class Union)

import Data.Maybe (Maybe(..))
import Data.Monoid (mempty)
import Effect.Console (log)
import Type.Proxy (Proxy(..))

data Maybe a = Just a | Nothing

-- Make sure that record updates get monomorphized.
asNothing :: forall a. { a :: Maybe a } -> { a :: Maybe a }
asNothing = _ { a = Nothing }
Expand All @@ -19,4 +19,11 @@ union _ _ = Proxy
shouldSolve :: forall a b. Proxy ( a :: Maybe a, b :: Maybe b )
shouldSolve = { a: Nothing } `union` { b: Nothing }

-- Removes ConstrainedTypeUnified
v1 :: { a :: Maybe Unit }
v1 = { a : Just unit }

v2 :: { a :: Maybe Unit }
v2 = let v3 = v1 { a = mempty } in v3

main = log "Done"