git.iko.soy/rowtype-yoga/purescript-native
on cd4c708 help sign in
rowtype-yoga/purescript-native/examples/passing/ExportedInstanceDeclarations.purs
45 lines 1.1 kB history raw
1-- Tests that instances for non-exported classes / types do not appear in the
2-- result of `exportedDeclarations`.
3module Main
4 ( Const(..)
5 , class Foo
6 , foo
7 , main
8 ) where
10import Prelude
11import Control.Monad.Eff.Console (log)
13data Const a b = Const a
15class Foo a where
16 foo :: a
18data NonexportedType = NonexportedType
20class NonexportedClass a where
21 notExported :: a
23-- There are three places that a nonexported type or type class can occur,
24-- leading an instance to count as non-exported:
25-- * Constraints
26-- * The type class itself
27-- * The instance types
29-- Case 1: constraints
30instance nonExportedFoo :: (NonexportedClass a) => Foo a where
31 foo = notExported
33-- Another instance of case 1:
34instance nonExportedFoo2 :: (Foo NonexportedType) => Foo (a -> a) where
35 foo = id
37-- Case 2: type class
38instance nonExportedNonexportedType :: NonexportedClass (Const Int a) where
39 notExported = Const 0
41-- Case 3: instance types
42instance constFoo :: Foo (Const NonexportedType b) where
43 foo = Const NonexportedType
45main = log "Done"