1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 21:16:12 +03:00

Define Recursive & Corecursive instances for Rose.

This commit is contained in:
Rob Rix 2017-04-12 14:37:05 -04:00
parent e50ec88a01
commit fb4415d5dc

View File

@ -1,4 +1,4 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GADTs, TypeFamilies #-}
module Data.Syntax.Assignment
( Assignment
, rule
@ -13,6 +13,7 @@ module Data.Syntax.Assignment
import Control.Monad.Free.Freer
import Data.Functor.Classes
import Data.Functor.Foldable
import Prologue hiding (Alt)
import Text.Show
@ -83,3 +84,11 @@ instance Show symbol => Show1 (AssignmentF symbol) where
Children a -> showsUnaryWith (liftShowsPrec sp sl) "Children" d a
Alt a b -> showsBinaryWith sp sp "Alt" d a b
Empty -> showString "Empty"
type instance Base (Rose a) = RoseF a
data RoseF a f = RoseF a [f]
deriving (Eq, Functor, Show)
instance Recursive (Rose a) where project (Rose a as) = RoseF a as
instance Corecursive (Rose a) where embed (RoseF a as) = Rose a as