This file contains hidden or 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 FoldMutRec where | |
-- Note: DeriveFoldable could be used, but I am providing | |
-- hand-written instances to better illustrate the mechanics. | |
import Data.Monoid | |
data Forest a = Forest [Tree a] | |
data Tree a = Node a (Forest a) |
This file contains hidden or 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
{-# LANGUAGE DataKinds, TypeOperators, GADTs, TypeFamilies #-} | |
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
module FirstField where | |
import Generics.SOP | |
class HasHead (y :: *) (xs :: [*]) where | |
hhead :: NP I xs -> K y xs | |
instance (x ~ y) => HasHead y (x ': xs) where |
NewerOlder