formal languages

This commit is contained in:
hi 2025-08-10 09:17:00 +00:00
parent 7eeb59c0e3
commit 4d7fd8be7c
2 changed files with 76 additions and 0 deletions

15
Logic/Language.hs Normal file
View file

@ -0,0 +1,15 @@
module Logic.Language where
-- Formal language (/grammar/production system/whatever)
class (Eq symbol, Show symbol) => Language symbol where
-- If Haskell had dependent types this could be generalized.
-- For now the languages I want to make use at most up to infer3.
infer0 :: [[symbol]]
infer1 :: [[symbol] -> [[symbol]]]
infer2 :: [[symbol] -> [symbol] -> [[symbol]]]
infer3 :: [[symbol] -> [symbol] -> [symbol] -> [[symbol]]]
-- Convenience newtype so strings are less ugly
newtype Seq symbol = Seq [symbol]
instance Show a => Show (Seq a) where
show (Seq xs) = concat $ map show xs