From a470fcc9974a7579f3e67c49743793524408f868 Mon Sep 17 00:00:00 2001 From: Johannes Merl Date: Wed, 21 Feb 2024 20:10:39 +0100 Subject: [PATCH] working generation of Lamda Individuals! \o/ --- src/GA.hs | 2 +- src/Test.hs | 35 ++++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/GA.hs b/src/GA.hs index 552d79f..441b210 100644 --- a/src/GA.hs +++ b/src/GA.hs @@ -46,7 +46,7 @@ type R = Double -- An Environment that Individuals of type i can be created from -- It stores all information required to create and change Individuals correctly -- -class (Eq e, Pretty e, Individual i) => Environment i e where +class (Pretty e, Individual i) => Environment i e where -- | -- Generates a completely random individual. -- diff --git a/src/Test.hs b/src/Test.hs index ab82005..65dbf87 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} @@ -9,21 +8,35 @@ module Main where +import Data.Random +import Data.Typeable import qualified GA +import qualified LambdaCalculus import Protolude import qualified Seminar -import qualified LambdaCalculus -import Data.Typeable +import System.Random.MWC (createSystemRandom) import qualified Type.Reflection as Ref main :: IO () main = do - _ <- GA.runTests - _ <- Seminar.runTests - _ <- putStrLn $ ((show (typeRepArgs (Ref.SomeTypeRep (Ref.TypeRep @(Int->Int->Int->Text))))) :: Text) - _ <- putStrLn $ ((show (typeRepArgs (Ref.SomeTypeRep (Ref.TypeRep @(Text))))) :: Text) - _ <- putStrLn (LambdaCalculus.toLambdaExpressionShort LambdaCalculus.testIntToClassCorrect) - _ <- putStrLn $ ((show (LambdaCalculus.res 1)) :: Text) - _ <- putStrLn $ ((show (LambdaCalculus.res 2)) :: Text) - _ <- putStrLn $ ((show (LambdaCalculus.res 3)) :: Text) + --_ <- GA.runTests + --_ <- Seminar.runTests + --_ <- putStrLn $ ((show (typeRepArgs (Ref.SomeTypeRep (Ref.TypeRep @(Int -> Int -> Int -> Text))))) :: Text) + --_ <- putStrLn $ ((show (typeRepArgs (Ref.SomeTypeRep (Ref.TypeRep @(Text))))) :: Text) + mwc <- createSystemRandom + r <- sampleFrom mwc $ LambdaCalculus.new LambdaCalculus.exampleLE + _ <- putStrLn $ LambdaCalculus.toLambdaExpressionS $ r + r <- sampleFrom mwc $ LambdaCalculus.new LambdaCalculus.exampleLE + _ <- putStrLn $ LambdaCalculus.toLambdaExpressionS $ r + --_ <- putStrLn (LambdaCalculus.toLambdaExpressionShort LambdaCalculus.testIntToClassCorrect) + --_ <- putStrLn $ ((show (LambdaCalculus.res 1)) :: Text) + --_ <- putStrLn $ ((show (LambdaCalculus.res 2)) :: Text) + --_ <- putStrLn $ ((show (LambdaCalculus.res 3)) :: Text) return () + +if' :: Bool -> a -> a -> a +if' True x _ = x +if' False _ y = y + +--f :: Int -> Int -> Int +