mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-10 10:46:11 +03:00
Add a test for hihger-kinded coercions in damlc (#1386)
This commit is contained in:
parent
e70ec5c781
commit
871feeff67
22
daml-foundations/daml-ghc/tests/NewtypeHigherKinded.daml
Normal file
22
daml-foundations/daml-ghc/tests/NewtypeHigherKinded.daml
Normal file
@ -0,0 +1,22 @@
|
||||
-- Copyright (c) 2019, Digital Asset (Switzerland) GmbH and/or its affiliates.
|
||||
-- All rights reserved.
|
||||
|
||||
-- Check that we can handle higher-kinded coercion axioms like `App f ~ f`.
|
||||
-- We currently cannot handle the coercion `App f (Wrap a) ~ f a` in general.
|
||||
-- Let's make sure this does not creep up because GHC tries to be smart and
|
||||
-- simplifies `fmap coerce` to `coerce`.
|
||||
daml 1.2
|
||||
module NewtypeHigherKinded where
|
||||
|
||||
newtype App f a = App (f a)
|
||||
|
||||
newtype Wrap a = Wrap a
|
||||
|
||||
wrap : Functor f => f a -> App f (Wrap a)
|
||||
wrap xs = App (fmap Wrap xs)
|
||||
|
||||
unwrap : Functor f => App f (Wrap a) -> f a
|
||||
unwrap (App xs) = fmap (\(Wrap x) -> x) xs
|
||||
|
||||
main = scenario do
|
||||
assert (unwrap (wrap [1]) == [1])
|
Loading…
Reference in New Issue
Block a user