-
Notifications
You must be signed in to change notification settings - Fork 139
Implement Test.CodeWars.BlackList for Haskell 8 #691
Comments
I think we just need to use Language.Haskell.Exts.Parser instead. I'll see if I can make it work, but if not, I guess I can add haskell-src-exts and let the community come up with something usable based on that, then extract that into a new module that can be included. |
That's a bad news (that there is some insanity). Can you add |
Yeah, I started reading the documentation and it seemed to have changed a lot. I can't find the replacement for I'll add Solution can be read from I'll let you know when it's deployed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Added |
Tried a few things, and it seems to be straightforward. Given the source code module Example where
import Prelude hiding (Bool(..), head, (/))
import Data.Maybe
import qualified Data.Map as Map
import Data.Map (Map(..), fromList)
import Data.Set (Set)
import Data.Monoid (Dual(getDual)) the import list from the result of [
ImportDecl {
importAnn = (), importModule = ModuleName () "Prelude",
importQualified = False, importSrc = False, importSafe = False,
importPkg = Nothing, importAs = Nothing,
importSpecs = Just (
ImportSpecList () True [
IThingAll () (Ident () "Bool"),
IVar () (Ident () "head"),
IVar () (Symbol () "/")
]
)
},
ImportDecl {
importAnn = (), importModule = ModuleName () "Data.Maybe",
importQualified = False, importSrc = False, importSafe = False,
importPkg = Nothing, importAs = Nothing, importSpecs = Nothing
},
ImportDecl {
importAnn = (), importModule = ModuleName () "Data.Map",
importQualified = True, importSrc = False, importSafe = False,
importPkg = Nothing, importAs = Just (ModuleName () "Map"), importSpecs = Nothing
},
ImportDecl {
importAnn = (), importModule = ModuleName () "Data.Map",
importQualified = False, importSrc = False, importSafe = False,
importPkg = Nothing, importAs = Nothing,
importSpecs = Just (
ImportSpecList () False [
IThingAll () (Ident () "Map"),
IVar () (Ident () "fromList")
]
)
},
ImportDecl {
importAnn = (), importModule = ModuleName () "Data.Set",
importQualified = False, importSrc = False, importSafe = False,
importPkg = Nothing, importAs = Nothing,
importSpecs = Just (
ImportSpecList () False [
IAbs () (NoNamespace ()) (Ident () "Set")
]
)
},
ImportDecl {
importAnn = (), importModule = ModuleName () "Data.Monoid",
importQualified = False, importSrc = False, importSafe = False,
importPkg = Nothing, importAs = Nothing,
importSpecs = Just (
ImportSpecList () False [
IThingWith () (Ident () "Dual") [VarName () (Ident () "getDual")]
]
)
}
] The relevant parts for
|
Ok, finished writing |
@Bubbler-4 Looks great! I don't think we need to be 100% compatible (unless we really need to keep GHC 7.10 compatibility for some reason) so we can have separate functions if that makes sense. Maybe we can create We can also name the function to match other assertions. Something like |
That module name is a good idea. I think solutionImports `shouldHide` Module "Data.List"
solutionImports `shouldHide` FromModule "Data.List" "tail" or, probably better: solutionShouldHide $ Module "Data.List"
solutionShouldHide $ FromModule "Data.List" "tail"
solutionShouldHideAll [Module "Data.List", Module "Data.Set", Module "Data.Map"] Just for reminder, there's one more must-have for |
Yeah, I like For |
Well, I already made a complete module including approx assertions (with descriptive failure messages), so you don't need HUnit-approx (which is IMO somewhat obscure in terms of epsilon). |
@Bubbler-4 Looks great! I'll make a repository under Codewars org. Maybe https://github.com/Codewars/hspec-codewars . So you can open a PR and we can maintain this. |
@Bubbler-4 can you open a PR on Codewars/hspec-codewars so you get the credit? Just adding a file |
PR submitted. Codewars is just perfect for slacking at work (just kidding :) |
|
Name: Test.CodeWars.BlackList
Language Name: Haskell 8
Website: Within codewars-runner-cli repo
Why?
For library re-implementation challenges, e.g. transpose or fold or whatever, the
hidden
feature is necessary to stop people import that exact thing. Unfortunately, its access is limited to legacy Haskell (v7), so any kata that has ahidden
test is stuck to v7 and therefore out of future support. (Not that writing a new kata that requireshidden
is a good idea in the first place...)Is it possible?
Looking at its imports, simply having that file alongside the solution/test.hs files should enable
import Test.CodeWars.BlackList
, unless there's some insanity inLanguage.Haskell.Exts.*
.The text was updated successfully, but these errors were encountered: