Skip to content

Instantly share code, notes, and snippets.

@quartorz
Created March 20, 2021 10:00
Show Gist options
  • Save quartorz/f3928db7403307b5981beb5bf9e85b45 to your computer and use it in GitHub Desktop.
Save quartorz/f3928db7403307b5981beb5bf9e85b45 to your computer and use it in GitHub Desktop.
SymbolのリストとTypeから、Typeがすべて等しいRowを作る
module HomogeneousRow where
import Prim.Row (class Cons, class Lacks)
import Type.Data.List (Cons', List', Nil')
class HomogeneousRow :: forall k. List' -> k -> Row k -> Constraint
class HomogeneousRow list k row | list k -> row, row -> list
instance homogeneousRow :: HomogeneousRow Nil' typ ()
else instance homogeneousRowCons ::
( Lacks sym row'
, Cons sym typ row' row
, HomogeneousRow tail typ row'
) =>
HomogeneousRow (Cons' sym tail) typ row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment