Comments (7)
Uh oh. The version currently on Github is missing a fix that is in the dev version I have locally. It's the same issue as #4.
@lemonidas: can you synchronize this repo with the private one, or should I make a pull request here?
from luck.
Hello,
It appears that this option is no longer used since the last big update. To run luck many times, the easiest way is probably to make it a generator in Haskell. There is only one example of this at the moment, exampes-template/combination.hs
.
-
We need matching type declarations in Luck and in Haskell. In particular, the order of type constructors must be the same, and the Haskell type must derive an instance of
Data
.In Luck, the function to turn into a predicate should appear last in the file,
and only functions up to three arguments are currently supported.fun closedTerm :: Term -> Bool
{-# LANGUAGE DeriveDataTypeable, TemplateHaskell #-}
import Data.Data
import Luck.Template
import Test.QuickCheck
data Type = TArrow Type Type
| TList
| TInt
deriving (Show, Data)
data Term = Var Int
| Abs Int Type Term
| App Type Term Term
deriving (Show, Data)
-- Tweak _maxUnroll for performance
gen :: Gen (Maybe Term)
gen = $(mkGenQ defFlags{_fileName="examples/STLC.luck",_maxUnroll=2}) TProxy1
-- gen is a regular QuickCheck generator
main = sample gen
from luck.
@Lysxia great, thank you!
from luck.
@Lysxia well, I have a problem with your example also :( If i try to compile it as is, I get:
[1 of 1] Compiling Main ( examples-template/Stlc-2.hs, examples-template/Stlc-2.o )
examples-template/Stlc-2.hs:19:16: error:
• Couldn't match type ‘Flags’ with ‘[Char]’
Expected type: String
Actual type: Flags
• In the first argument of ‘mkGenQ’, namely
‘defFlags {_fileName = "examples/STLC.luck", _maxUnroll = 2}’
In the expression:
mkGenQ
(defFlags {_fileName = "examples/STLC.luck", _maxUnroll = 2})
In the untyped splice:
$(mkGenQ
(defFlags {_fileName = "examples/STLC.luck", _maxUnroll = 2}))
If I try it the way I see in other examples-template
, that is:
gen = $(mkGenQ "examples/STLC.luck") defFlags{_maxUnroll=2} TProxy1
I have another error:
[1 of 1] Compiling Main ( examples-template/Stlc-2.hs, examples-template/Stlc-2.o )
examples-template/Stlc-2.hs:19:9: error:
• Couldn't match type ‘Data.ByteString.Internal.ByteString’
with ‘[Outer.AST.Decl]’
Expected type: Outer.AST.Prg
Actual type: Data.ByteString.Internal.ByteString
• In the second argument of ‘Luck.Main.parse’, namely
‘Data.ByteString.Char8.pack
"data Maybe a = Just a | Nothing\n\
\\n\
\fun or u w1 w2 e1 e2 = \n\
\ case u of \n\
\ | w1 % True -> \n\
...
(the whole text of Prelude.luck and STLC.luck)
Any ideas how to fix this?
from luck.
I got the power to fix this! This example should compile now: https://github.com/QuickChick/Luck/blob/master/luck/examples-template/Stlc-template.hs
For some reason it feels a bit slow, I don't know how fast you need it to be. I would also recommend looking at lazysmallcheck and lazy-search. They should be easier to use because you can write the "well-typed" predicate in Haskell, although you lose control over the resulting distribution.
Have you also seen "Making random judgements" for generating well-typed terms, with a racket implementation (with the purpose of testing compilers)? Porting it to Haskell seems a lot of work, but it may still be useful to you.
from luck.
It works now, thanks so much for your help!
I don't care much about language it is implemented in, because our compiler under consideration is in C, and I feel we'll end up making FFI's anyway. I just feel less comfortable with Racket than Haskell, so I decided to give Luck a try. Although, the whole testing strategy is not totally clear for me (seems that not many predicates we can check about our compiler's output), so I didn't really invest much time in this so far. We'll see if it turns into something interesting…
from luck.
You're welcome!
Feel free to get in touch if anything comes up. I'll clean up the CLI and docs if I find the time.
from luck.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luck.