Created
April 25, 2018 21:34
-
-
Save chexxor/5b491d55ea9187cd1020d034818711e5 to your computer and use it in GitHub Desktop.
HomoHKTRow.purs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Prelude | |
import Control.Monad.Eff.Console (log) | |
import TryPureScript (render, withConsole) | |
import Type.Row | |
class HomoHKTRow (rs :: RowList) (f :: Type -> Type) | |
instance allFoosNil :: HomoHKTRow Nil f | |
instance allFoosCons :: (HomoHKTRow t f) => HomoHKTRow (Cons l (f h) t) f | |
data Foo a = Foo a | |
class FooRecord a | |
instance foozA :: (RowToList r rl, HomoHKTRow rl Foo) => FooRecord (Record r) | |
allFoos :: forall r. FooRecord r => r -> Unit | |
allFoos _ = unit | |
-- or without the `FooRecord` class | |
allFoos' :: forall r rl. | |
RowToList r rl => | |
HomoHKTRow rl Foo => | |
(Record r) -> Unit | |
allFoos' _ = unit | |
demo :: Unit | |
demo = allFoos { x: Foo 3, y: Foo "test" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment