Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Webapp #118

Open
wants to merge 175 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
fd73c77
new webapp uses react/redux
michaelbjames Feb 21, 2020
001545c
wip
michaelbjames Feb 21, 2020
2258527
WIP
Feb 21, 2020
280fd9b
refactor type checking module
Feb 22, 2020
f657e1c
add support for example checking
Feb 22, 2020
f538443
add bootstrap
michaelbjames Feb 22, 2020
4c4d1b9
table is editable, with hard coded columns
michaelbjames Feb 23, 2020
a6ffe96
show usage table
michaelbjames Feb 23, 2020
5496796
reorganize and reduce boilerplate -- add redux dev toolkit
michaelbjames Feb 24, 2020
6a762e6
add json string parsing
Feb 24, 2020
1a6a2c4
support for io json
Feb 24, 2020
f15bfc8
pass code to candidate list
michaelbjames Feb 24, 2020
72331b0
updated web readme
michaelbjames Feb 24, 2020
a4b4f3c
add promise to mock adding a candidate
michaelbjames Feb 24, 2020
5e96cfa
include spinner
michaelbjames Feb 24, 2020
305ab96
add usage up top
michaelbjames Feb 24, 2020
720f39c
support for output as ??
Feb 24, 2020
90bd5c1
change default parameters
Feb 25, 2020
064ec9b
add new route, for getting result about one usage
michaelbjames Feb 25, 2020
a25aa66
add loading and error states to the usage table
michaelbjames Feb 25, 2020
7aff0aa
manipulate usage / examples
michaelbjames Feb 25, 2020
d29cfb5
switch to LogicT
Feb 25, 2020
f06c376
minor fix
Feb 25, 2020
2621dc8
WIP
Feb 27, 2020
e5c363c
WIP: update logic monad
aaronguo1996 Feb 27, 2020
c99793f
WIP: update time stats
aaronguo1996 Feb 27, 2020
0ed3a8a
fix the minor bugs
aaronguo1996 Feb 27, 2020
61062ce
fix the minor bugs (#61, #43)
aaronguo1996 Feb 27, 2020
6002f13
Merge branch 'zheng_param_order' of github.com:davidmrdavid/hoogle_pl…
aaronguo1996 Feb 27, 2020
d2d48d6
init web server
aaronguo1996 Feb 28, 2020
24ea147
add builtin json
aaronguo1996 Feb 28, 2020
7fa06fc
Merge branch 'zheng_param_order' into zheng_mid_layer
aaronguo1996 Feb 28, 2020
9335b25
add start script (#64)
Feb 28, 2020
9b792e5
use react-bootstrap; include base modal
michaelbjames Feb 28, 2020
8909b4c
modal pops up
michaelbjames Feb 28, 2020
dd2cc00
UI will pop up when no type is entered. needs styling
michaelbjames Feb 28, 2020
3963f3d
add more json format for web (#64)
aaronguo1996 Feb 28, 2020
2147d86
Merge branch 'zheng_mid_layer' of github.com:davidmrdavid/hoogle_plus…
aaronguo1996 Feb 28, 2020
d1e4cf6
add more examples (#64)
aaronguo1996 Feb 28, 2020
56a82fe
fix minor bugs
aaronguo1996 Feb 28, 2020
c5a46b0
fix compilation error
aaronguo1996 Feb 28, 2020
c3c204c
use accordian cards for candidate list
michaelbjames Feb 28, 2020
b0635ef
update existing example specs
michaelbjames Feb 28, 2020
ecd994e
break out spinnable cell
michaelbjames Feb 28, 2020
7379ad7
generate new example gets uuid
michaelbjames Feb 28, 2020
a8d9702
change an example spec, prop down
michaelbjames Feb 28, 2020
031d549
update routes
michaelbjames Feb 29, 2020
1105552
update hplus for all routes support (#64)
aaronguo1996 Feb 29, 2020
91644e6
propagate changes across usage
michaelbjames Feb 29, 2020
8b7e650
Merge branch 'mj_new_webapp' of github.com:/davidmrdavid/hoogle_plus …
michaelbjames Feb 29, 2020
0d42568
add more examples button
michaelbjames Feb 29, 2020
d82e3ac
bugfix: keep usage on updated result overwrites previous spec
michaelbjames Mar 2, 2020
35510b2
add error support (#64)
aaronguo1996 Mar 3, 2020
808f548
cannot test stop, wait for front end
aaronguo1996 Mar 3, 2020
2fc46bc
try to fetch first
michaelbjames Mar 3, 2020
74dd678
use development flag
michaelbjames Mar 3, 2020
22de2cf
Merge branch 'zheng_mid_layer' into mj_new_webapp
michaelbjames Mar 3, 2020
243dd5b
change request json parse method
aaronguo1996 Mar 3, 2020
a464525
use flask port and disable CORS check
michaelbjames Mar 3, 2020
a6fe972
Merge remote-tracking branch 'origin/zheng_mid_layer' into mj_new_webapp
michaelbjames Mar 3, 2020
8277818
live request for type
michaelbjames Mar 4, 2020
c937269
permit CORS
michaelbjames Mar 4, 2020
3f9e6d9
WIP search for types from examples endpoint
michaelbjames Mar 4, 2020
5bd10c1
move gateway files
michaelbjames Mar 4, 2020
6bb40c6
error is not loading
michaelbjames Mar 4, 2020
ab3760d
enter to submit type query
michaelbjames Mar 4, 2020
1f44327
convert to json
michaelbjames Mar 4, 2020
3a654c3
add feature manager to disable features selectively
michaelbjames Mar 5, 2020
3b9f652
update readme
michaelbjames Mar 5, 2020
700eb27
return a monotype when search types (#70)
aaronguo1996 Mar 5, 2020
2d8cf71
dont send empty facts
michaelbjames Mar 6, 2020
b32c352
add new type inference algorithm
aaronguo1996 Mar 8, 2020
696fede
fix minor bugs in type inference algorithm
Mar 9, 2020
05c320a
permute arguments in query types
Mar 9, 2020
f36d5bb
pretty print infix operators (#51)
Mar 9, 2020
1dd477c
fix bugs in arg permutations
Mar 9, 2020
2a7d9ca
rule out error generalization
Mar 9, 2020
ac0ebf8
Merge remote-tracking branch 'origin/zheng_mid_layer' into new_webapp
michaelbjames Mar 9, 2020
75b6d01
send examples with correct format; modal looks better
michaelbjames Mar 9, 2020
f3e0af9
use inputs/output format elsewhere
michaelbjames Mar 9, 2020
3159853
use examplesStatus in the default state of the new candidates
michaelbjames Mar 9, 2020
9db15e8
show error message for more examples button
michaelbjames Mar 10, 2020
5862830
move baseroute to the fetches utility file
michaelbjames Mar 10, 2020
4c16e7c
centered table headers
michaelbjames Mar 10, 2020
0245145
Merge back (#72)
michaelbjames Mar 11, 2020
0acf0f2
better layout, with syntax highlighting
michaelbjames Mar 11, 2020
f6d3c5b
break apart search
michaelbjames Mar 11, 2020
29ba003
WIP
michaelbjames Mar 11, 2020
60196f4
set loading on search
michaelbjames Mar 11, 2020
335140a
remove dead component
michaelbjames Mar 11, 2020
d457754
remove dead action type
michaelbjames Mar 11, 2020
575adf5
Incremental Checkin (#78)
michaelbjames Mar 11, 2020
1b93839
pass documents from hoogle to front end
Mar 12, 2020
b9f0c64
fix bug for hof
Mar 12, 2020
e345cb3
add timeout in case of infinite execution
Mar 12, 2020
559d678
fix format bugs
Mar 12, 2020
a73e8dc
prevent empty fold
michaelbjames Mar 12, 2020
808da5f
fix hoogle db path
Mar 12, 2020
ddfc43d
Mj webapp docs (#84)
michaelbjames Mar 12, 2020
1a34aab
Merge branch 'zheng_mid_layer' into new_webapp
Mar 13, 2020
f927da3
Merge remote-tracking branch 'origin/mj_new_webapp' into new_webapp
Mar 13, 2020
f7e47be
fixed alignment and styling on page (#83)
shivanidoshi26 Mar 13, 2020
f3ffa0f
fix path error (#81)
Mar 13, 2020
3af1f32
Merge branch 'zheng_mid_layer' into new_webapp
Mar 13, 2020
6b5bac5
Hp new webapp (#82)
peleghila Mar 13, 2020
29674c0
pre study UI fixes (#86)
michaelbjames Mar 13, 2020
702274d
accept example changes (#87)
michaelbjames Mar 14, 2020
f1b5914
Zheng mid layer (#89)
aaronguo1996 Mar 14, 2020
4ce38df
Merge branch 'new_webapp' of github.com:davidmrdavid/hoogle_plus into…
Mar 14, 2020
087c9cd
counting args correctly (#90)
peleghila Mar 16, 2020
b8bd143
use Hoogle+ instead of React-App
michaelbjames Mar 16, 2020
b10b162
Merge branch 'new_webapp' of github.com:davidmrdavid/hoogle_plus into…
Mar 17, 2020
c5a14bf
Fix argname issue and a filter bug in h+ (#97)
aaronguo1996 Mar 17, 2020
4703cbb
add stop button and support (#104)
aaronguo1996 Mar 21, 2020
ad5384d
New example table (#107)
michaelbjames Mar 22, 2020
a7f6e83
show alert on error instead of blocking input (#108)
michaelbjames Mar 23, 2020
beb3e3c
More Examples (#109)
michaelbjames Mar 23, 2020
a07ef14
Docs on tooltip (#110)
michaelbjames Mar 23, 2020
510e7ea
Cleanup
michaelbjames Mar 25, 2020
790a6ff
add new usages
michaelbjames Mar 25, 2020
d963a64
Zheng tyclass (#111)
aaronguo1996 Mar 25, 2020
4c70a61
Merge branch 'new_webapp' of github.com:davidmrdavid/hoogle_plus into…
Mar 25, 2020
19726a9
fix merge bug
Mar 25, 2020
9469148
handle errors with example update call
michaelbjames Mar 26, 2020
cc23ec4
Merge branch 'new_webapp' of github.com:/davidmrdavid/hoogle_plus int…
michaelbjames Mar 26, 2020
f9886c9
fix stop button issues (#115)
michaelbjames Mar 27, 2020
f6a0ee6
add dependencies.txt
michaelbjames Mar 27, 2020
d028b4b
Merge branch 'new_webapp' of github.com:davidmrdavid/hoogle_plus into…
michaelbjames Mar 27, 2020
53a5145
stop button can only be pressed when you can stop something
michaelbjames Mar 27, 2020
17c23e1
Zheng hot fix (#116)
aaronguo1996 Mar 27, 2020
4eaed08
revert the type checking for examples (#117)
aaronguo1996 Mar 27, 2020
a75225e
search for type hotfix
michaelbjames Mar 27, 2020
74ebabb
Zheng example generate (#119)
aaronguo1996 Apr 2, 2020
f3e7e5c
Zheng webapp fix (#121)
aaronguo1996 Apr 2, 2020
0ea8df0
Zheng webapp fix2 (#122)
aaronguo1996 Apr 3, 2020
84abc80
Pilot fixes (#123)
michaelbjames Apr 6, 2020
865911a
fix packages deps
michaelbjames Apr 6, 2020
779f462
flavortext change
michaelbjames Apr 9, 2020
bfa3a39
Zheng cherry pick (#124)
aaronguo1996 Apr 10, 2020
e7c4e21
pilot fixes (#132)
michaelbjames Apr 13, 2020
95d7e4c
Pretty-print HOF IOs, Fix non-termination evaluation (#131)
mistzzt Apr 13, 2020
0659c56
Zheng infer tyclass (#134)
aaronguo1996 Apr 16, 2020
c55cf37
Zheng infer bug (#136)
aaronguo1996 Apr 17, 2020
3053add
Optimize not failing check and implement more examples (#135)
mistzzt Apr 17, 2020
cf43e67
move print earlier
Apr 17, 2020
1122a25
Zheng infer order (#137)
aaronguo1996 Apr 17, 2020
ff6a2cb
FE Parser (#141)
michaelbjames Apr 20, 2020
f77d29d
refine text bug
michaelbjames Apr 21, 2020
afadcee
Zheng merge filter (#142)
aaronguo1996 Apr 22, 2020
97cd5bf
Include supertype conversion functions for typeclass heirarchy ord ->…
michaelbjames Apr 22, 2020
09ef868
Merge branch 'new_webapp' of github.com:davidmrdavid/hoogle_plus into…
michaelbjames Apr 22, 2020
6d429cc
Zheng func print (#144)
aaronguo1996 Apr 22, 2020
f33b46e
Implement strategy 1 and upload script comparing strategy (#145)
aaronguo1996 Apr 23, 2020
3b55f24
feed and print nice functions (#146)
aaronguo1996 Apr 23, 2020
e4cd0d4
move from x*2 to x*3
aaronguo1996 Apr 23, 2020
094977d
left align docs, fix example error (#147)
aaronguo1996 Apr 24, 2020
3dd5a85
Wrap negative numbers (#148)
aaronguo1996 Apr 24, 2020
68e696f
fix issues for function arities more than 2; fix issues for function …
aaronguo1996 Apr 24, 2020
16c1dbd
Loading block on usage change; add usage to 1 cand
michaelbjames Apr 26, 2020
9ad7cd0
put a new usage at the TOP of the list
michaelbjames Apr 28, 2020
4cc7db3
fix issue #150
aaronguo1996 May 4, 2020
fd99e23
Add `CompareSolutions` experiment script
mistzzt May 6, 2020
3d3a127
Fix script
mistzzt May 6, 2020
b669b13
Revert cherry pick
mistzzt May 6, 2020
9e77916
inference eval; bug fix for inference
aaronguo1996 May 7, 2020
e775d93
experiments
aaronguo1996 May 11, 2020
517dbf7
Merge branch 'ziteng_rank_full' of github.com:davidmrdavid/hoogle_plu…
aaronguo1996 May 11, 2020
72b084a
fix #151
aaronguo1996 May 11, 2020
f5324a9
Zheng infer eval (#153)
aaronguo1996 May 28, 2020
66fc57c
Update container
mistzzt Jul 2, 2020
6f14e00
merge
aaronguo1996 Jul 9, 2020
4b2a8e5
expose port for flask
aaronguo1996 Jul 19, 2020
d230921
Zheng infer eval (#158)
aaronguo1996 Aug 4, 2020
a375823
fix for website depolyment
Nov 4, 2020
eaae4e6
fix type checking for PApp
aaronguo1996 Nov 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mistzzt/haskell-ide-engine:0.11-ghc8.4.4
FROM mistzzt/haskell-ide-engine:1.4-ghc8.4.4

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "H+ w/ HIE(G) 0.11",
"image": "mistzzt/hoogle_plus_dev:latest",
"name": "H+ w/ HIE 1.4, GHC 8.4.4",
"image": "mistzzt/hoogle_plus_dev:hie1.4_ghc8.4.4",

"extensions": [
"eamodio.gitlens",
Expand Down
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,45 @@ benchmark/suites/working.yml
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

node_modules/
.yarn
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# flask
venv/

*.pyc
__pycache__/

instance/

.pytest_cache/
.coverage
htmlcov/

dist/
build/
*.egg-info/
218 changes: 195 additions & 23 deletions InternalTypeGen.hs
Original file line number Diff line number Diff line change
@@ -1,39 +1,211 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies, LambdaCase, FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances, FunctionalDependencies #-}
module InternalTypeGen where

import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Gen
import Data.List (isInfixOf, elemIndex, nub, drop, reverse, intersect)
import Control.Monad
import Control.Monad.State
import Control.Monad.Logic
import Data.Data

import Text.Printf
import System.IO.Silently
import Control.Lens
import Debug.Trace

import qualified Test.LeanCheck.Function.ShowFunction as SF
import qualified Test.LeanCheck.Core as SF
import qualified Test.ChasingBottoms as CB
import Data.Map (Map)
import Data.List (isInfixOf)
import Control.Applicative

isEqualResult lhs rhs = case (lhs, rhs) of
(CB.Value a, CB.Value b) -> a == b
(CB.NonTermination, CB.NonTermination) -> True
(CB.Exception _, CB.Exception _) -> True
_ -> False
import qualified Test.SmallCheck.Series as SS
import qualified Test.QuickCheck as QC

defaultShowFunctionDepth = 4 :: Int
defaultMaxOutputLength = 10 :: CB.Nat
defaultSeriesLimit = 5 :: Int

instance Eq a => Eq (CB.Result a) where
(CB.Value a) == (CB.Value b) = a == b
CB.NonTermination == CB.NonTermination = True
(CB.Exception _) == (CB.Exception _) = True
_ == _ = False

isFailedResult :: CB.Result String -> Bool
isFailedResult result = case result of
CB.NonTermination -> True
CB.Exception _ -> True
CB.Value a | "_|_" `isInfixOf` a -> True
CB.Value a | "Exception" `isInfixOf` a -> True
_ -> False

newtype Internal a = Val a
data MyInt = MOne | Zero | One | Two | Other Int deriving (Eq)

instance Show MyInt where
show = show . toInt

toInt :: MyInt -> Int
toInt MOne = -1
toInt Zero = 0
toInt One = 1
toInt Two = 2
toInt (Other n) = n

toMyInt :: Int -> MyInt
toMyInt (-1) = MOne
toMyInt 0 = Zero
toMyInt 1 = One
toMyInt 2 = Two
toMyInt n = Other n

instance SF.Listable MyInt where
tiers = SF.cons0 MOne SF.\/
SF.cons0 Zero SF.\/
SF.cons0 One SF.\/
SF.cons0 Two SF.\/
SF.cons1 Other

instance Monad m => SS.Serial m MyInt where
series = SS.cons0 MOne SS.\/
SS.cons0 Zero SS.\/
SS.cons0 One SS.\/
SS.cons0 Two

instance Monad m => SS.CoSerial m MyInt where
coseries r = let rs = SS.limit defaultSeriesLimit r
in SS.alts0 rs >>- \z1 ->
SS.alts0 rs >>- \z2 ->
SS.alts0 rs >>- \z3 ->
SS.alts0 rs >>- \z4 ->
return $ \x ->
case x of
MOne -> z1
Zero -> z2
One -> z3
Two -> z4

newtype MyFun a b = MyFun (a -> b)

instance (QC.CoArbitrary a, QC.Arbitrary b) => QC.Arbitrary (MyFun a b) where
arbitrary = liftM MyFun QC.arbitrary

instance (QC.Arbitrary a, QC.CoArbitrary b) => QC.CoArbitrary (MyFun a b) where
coarbitrary (MyFun f) = QC.coarbitrary f

instance {-# OVERLAPPABLE #-} (SS.Serial m b, SS.CoSerial m a) => SS.Serial m (MyFun a b) where
series = SS.coseries SS.series >>-
\f -> return (MyFun f)

instance {-# OVERLAPPING #-} Monad m => SS.Serial m (MyFun Int Int) where
series = (SS.generate $ \_ -> map MyFun [\x -> x + 1
,\x -> x * x
,\x -> x * 3]) SS.\/
SS.newtypeCons MyFun
instance {-# OVERLAPPING #-} Monad m => SS.Serial m (MyFun MyInt Int) where
series = (SS.generate $ \_ -> map MyFun [\x -> toInt x + 1
,\x -> toInt x * toInt x
,\x -> toInt x * 3]) SS.\/
(SS.coseries SS.series >>-
\f -> return (MyFun f))
instance {-# OVERLAPPING #-} Monad m => SS.Serial m (MyFun [Int] [Int]) where
series = (SS.generate $ \_ -> map MyFun [\x -> x ++ x]) SS.\/
SS.newtypeCons MyFun
instance (SS.CoSerial m a, SS.Serial m a, SS.Serial m b, SS.CoSerial m b) => SS.CoSerial m (MyFun a b) where
coseries rs = SS.newtypeAlts rs >>- \f ->
return $ \(MyFun x) -> f x

instance {-# OVERLAPPABLE #-} (Show a, SF.Listable a, SF.ShowFunction b) => Show (MyFun a b) where
show (MyFun f) = "(" ++ SF.showFunctionLine defaultShowFunctionDepth f ++ ")"
instance {-# OVERLAPPING #-} (SF.ShowFunction b) => Show (MyFun MyInt b) where
show (MyFun f) = "(" ++ SF.showFunctionLine defaultShowFunctionDepth (\x -> f (toMyInt x)) ++ ")"

instance SF.ShowFunction MyInt where
bindtiers = SF.bindtiers . toInt
instance (Show a, SF.Listable a, SF.ShowFunction b) => SF.ShowFunction (MyFun a b) where
bindtiers (MyFun f) = SF.bindtiers f

class Unwrappable a b where
unwrap :: a -> b
wrap :: b -> a

instance {-# OVERLAPPABLE #-} (a ~ b) => Unwrappable a b where
unwrap = id
wrap = id
instance Unwrappable MyInt Int where
unwrap = toInt
wrap = toMyInt
instance (Unwrappable a c, Unwrappable b d) => Unwrappable (MyFun a b) (c -> d) where
unwrap (MyFun f) = \x -> unwrap (f (wrap x))
wrap f = MyFun $ \x -> wrap (f (unwrap x))
instance (Unwrappable a b) => Unwrappable [a] [b] where
unwrap = map unwrap
wrap = map wrap
instance {-# OVERLAPPING #-} (Unwrappable a b) => Unwrappable (Maybe a) (Maybe b) where
unwrap = fmap unwrap
wrap = fmap wrap
instance (Unwrappable a c, Unwrappable b d) => Unwrappable (a, b) (c, d) where
unwrap (x, y) = (unwrap x, unwrap y)
wrap (x, y) = (wrap x, wrap y)


showCBResult :: CB.Result String -> String
showCBResult = \case
CB.Value a | "_|_" `isInfixOf` a -> "bottom"
CB.Value a -> a
CB.NonTermination -> "diverge"
CB.Exception ex -> show ex

anyDuplicate :: Eq a => [a] -> Bool
-- anyDuplicate xs = length (nub xs) /= length xs
anyDuplicate [] = False
anyDuplicate (x:xs) = x `elem` xs

-- * instance defined in `Types.IOFormat`
data Example = Example {
inputs :: [String],
output :: String
} deriving(Eq, Show)

type ExampleGeneration m = StateT [Example] m

evaluateIOQC :: Show a => [String] -> a -> ExampleGeneration IO String
evaluateIOQC inputs val = do
let result = show val
modify ((Example inputs result):)
return result

instance Show a => Show (Internal a) where
show (Val value) = show value
evaluateIO :: Data a => Int -> [String] -> [a] -> ExampleGeneration IO ([CB.Result String])
evaluateIO timeInMicro inputs vals = do
results <- liftIO $ silence $ mapM (CB.timeOutMicro timeInMicro . eval) vals

let resultsStr = map showCBResult results
modify ((++) (map (Example inputs) resultsStr))
return results
where
evalStr val = CB.approxShow defaultMaxOutputLength val
io str = ((putStrLn str) >> return str)

instance Arbitrary a => Arbitrary (Internal a) where
arbitrary = Val <$> arbitrary
eval val = io (evalStr val)

waitState :: Int -> [String] -> [String] -> [[String]] -> CB.Result String -> ExampleGeneration IO Bool
waitState numIOs args previousRets previousArgs ret = case (not $ isFailedResult ret) of
False -> pure False
_ -> do
ioState <- get

instance {-# OVERLAPPING #-} Arbitrary (Internal Int) where
arbitrary = Val <$> choose (5, 10)
let retStr = showCBResult ret
when (retIsNotInState retStr ioState && paramsIsNotInState args ioState)
(modify ((:) (Example args retStr)))

instance {-# OVERLAPPING #-} Arbitrary (Internal Char) where
arbitrary = Val <$> choose ('A', 'D')
state <- get
return ((length state) == numIOs)
where
retIsNotInState retStr state = not $ ((retStr `elem` (map output state)) || (retStr `elem` previousRets))
paramsIsNotInState params state = not (anyCommonArgs params (map inputs state ++ previousArgs))

instance {-# OVERLAPPING #-} Arbitrary (Internal String) where
arbitrary = Val <$> vectorOf 5 (choose ('A', 'D'))
-- modify 2020/04/22 by Zheng
-- only compare arguments in the same position, intersect is too strict
anyCommonArgs :: [String] -> [[String]] -> Bool
anyCommonArgs args inputs = or $ map (compare args) inputs
where
compare :: [String] -> [String] -> Bool
compare xs = any (uncurry (==)) . zip xs
Loading