mirror of
https://github.com/github/semantic.git
synced 2024-11-28 18:23:44 +03:00
Add a little lambda calculus to toy with.
This commit is contained in:
parent
610acb7380
commit
ccf8e1a7b9
@ -1,6 +1,8 @@
|
||||
{-# LANGUAGE DataKinds, FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings, ScopedTypeVariables, TypeApplications, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
{-# LANGUAGE DataKinds, DeriveGeneric, FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, OverloadedStrings, ScopedTypeVariables, TypeApplications, TypeFamilies, TypeOperators, UndecidableInstances #-}
|
||||
module Serializing.SExpression.Precise
|
||||
( serializeSExpression
|
||||
, Expr(..)
|
||||
, Identifier(..)
|
||||
) where
|
||||
|
||||
import Data.ByteString.Builder
|
||||
@ -31,8 +33,9 @@ instance (ToSExpressionWithStrategy strategy t, strategy ~ ToSExpressionStrategy
|
||||
data Strategy = Generic | Show
|
||||
|
||||
type family ToSExpressionStrategy t :: Strategy where
|
||||
ToSExpressionStrategy Text = 'Show
|
||||
ToSExpressionStrategy _ = 'Generic
|
||||
ToSExpressionStrategy Text = 'Show
|
||||
ToSExpressionStrategy Integer = 'Show
|
||||
ToSExpressionStrategy _ = 'Generic
|
||||
|
||||
class ToSExpressionWithStrategy (strategy :: Strategy) t where
|
||||
toSExpressionWithStrategy :: proxy strategy -> t -> Int -> Builder
|
||||
@ -68,3 +71,10 @@ instance GToSExpression f => GToSExpression (M1 S s f) where
|
||||
|
||||
instance ToSExpression k => GToSExpression (K1 R k) where
|
||||
gtoSExpression k = pure . toSExpression (unK1 k)
|
||||
|
||||
|
||||
data Expr = Var Identifier | Lam Identifier Expr | App Expr Expr | Int Integer
|
||||
deriving (Generic)
|
||||
|
||||
newtype Identifier = Identifier Text
|
||||
deriving (Generic)
|
||||
|
Loading…
Reference in New Issue
Block a user