Commit a5cf5519053933671350c8a9d69851b140fa1bcf

  • avatar
  • Ville Tirronen <ville.tirronen @j…u.fi> (Committer)
  • Fri May 03 17:11:26 EEST 2019
  • avatar
  • Ville Tirronen <ville.tirronen @j…u.fi> (Author)
  • Fri May 03 17:11:26 EEST 2019
Drafting new, fast to develop exercises
.gitmodules
(3 / 0)
  
1010[submodule "bootstrap"]
1111 path = bootstrap
1212 url = https://github.com/twbs/bootstrap.git
13[submodule "TypeCount"]
14 path = TypeCount
15 url = aleator@ciao.it.jyu.fi:Code/TypeCount
NewFastExercises/BuildArgVector
(10 / 0)
  
1let concatMapSep = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/Text/concatMapSep
2let length = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/List/length
3let indexed = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/List/indexed
4let iterate = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/List/iterate
5in λ(t:List Text) ->
6 concatMapSep " "
7 { index : Natural, value : Text }
8 (λ(n:{ index : Natural, value : Text }) ->
9 "("++"x"++ Natural/show (n.index + 1)++" :: "++n.value++")")
10 (indexed Text t)
NewFastExercises/BuildParamVector
(8 / 0)
  
1let concatMapSep = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/Text/concatMapSep
2let length = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/List/length
3let iterate = https://github.com/dhall-lang/dhall-lang/raw/master/Prelude/List/iterate
4in λ(t:List Text) ->
5 concatMapSep " "
6 Natural
7 (λ(n:Natural) -> "x"++ Natural/show n)
8 (iterate (length Text t) Natural (λ(x : Natural) -> x + 1) 1)
NewFastExercises/DefaultTestAgainstModel
(22 / 0)
  
1λ(funName : Text) ->
2λ(argTypes : List Text) ->
3(./TestKinds).TestAgainstModel
4{ errorMsg =
5 λ(err : ./ModelErrorType)
6 → ''
7 Your function does not work like the model solution!
8
9 Your solution returns `${err.yours}` for `${err.input}` whereas the
10 model solution returns `${err.model}`.
11
12 (This is a problem since the model solution is the only
13 acceptable answer)
14 ''
15, testID = "againstModel"
16, code = let args = ./BuildArgVector argTypes in
17 ''
18{-# LINE 0 "DefaultTestAgainstModel"#-}
19againstModel = quickCheck $ \${./BuildParamVector argTypes} ->
20 Main.${funName} ${args} == Exercise.${funName} ${args}
21''
22}
NewFastExercises/Destutter.dhall
(23 / 0)
  
1{
2 identifier = "Destutter"
3,task = ''
4There is a factory where dangerous machinery is operated using a keypad. The
5factory worker wear gloves and they keypad is protected using plastic film.
6These safety measures cause the worker to press the same button multiple times
7in error.
8
9Help the factory worker by creating a function that removes consecutive
10duplicates from a list.
11''
12,model = ''
13{-#LINE 1 "Destutter.dhall.model"#-}
14destutter (x:y:xs)
15 | x == y = destutter (y:xs)
16 | otherwise = x:destutter (y:xs)
17destutter xs = xs
18''
19,tests = [
20 ./DefaultTestAgainstModel "destutter" ["[Int]"]
21
22 ]
23} : ./NewTaskType
NewFastExercises/Driver.hs
(2 / 0)
  
1module Driver where
2import Test.QuickCheck
NewFastExercises/ExtractModel
(5 / 0)
  
1λ(m:./NewTaskType) -> ''
2module Exercise where
3
4${m.model}
5''
NewFastExercises/ModelErrorType
(3 / 0)
  
1{yours : Text
2,model : Text
3,input : Text}
NewFastExercises/NewTaskType
(5 / 0)
  
1{identifier : Text
2,model : Text
3,tests : List ./TestKinds
4,task : Text
5}
NewFastExercises/ReverseAList.dhall
(16 / 0)
  
1{
2 identifier = "NaiveReverse"
3,task = ''
4Write a function to reverse a list.
5''
6,model = ''
7{-#LINE 1 "ReverseAList.dhall.model"#-}
8reverseList :: [a] -> [a]
9reverseList [] = []
10reverseList (x:xs) = reverse xs ++ [x]
11''
12,tests = [
13 ./DefaultTestAgainstModel "reverseList" ["String"]
14
15 ]
16} : ./NewTaskType
NewFastExercises/Studies.txt
(8 / 0)
  
1* It *is* possible to obtain counterexamples from quickcheck:
2 <http://hackage.haskell.org/package/quickcheck-with-counterexamples-1.2/docs/Test-QuickCheck-Counterexamples.html>
3
4* TestKinds is probably an overkill if I go with the 'template-everything-as-strings' model
5
6* Indentation is making stuff nastier than it could be...
7
8* I probably should do explicit forAlls and named generators instead..
NewFastExercises/TestAttributesType
(1 / 0)
  
1{ errorMsg : ./ModelErrorType → Text, code : Text, testID : Text }
NewFastExercises/TestExpr
(4 / 0)
  
1let handlers = {TestAgainstModel = λ(x:./TestAttributesType) ->
2 x.code
3 ,FixedInput = λ(x:{}) -> ""}
4in λ(t:./TestKinds) -> merge handlers t : Text
NewFastExercises/TestKinds
(2 / 0)
  
1< TestAgainstModel : ./TestAttributesType
2| FixedInput : {} >
NewFastExercises/TestName
(4 / 0)
  
1let handlers = {TestAgainstModel = λ(x:./TestAttributesType) ->
2 x.testID
3 ,FixedInput = λ(x:{}) -> ""}
4in λ(t:./TestKinds) -> merge handlers t : Text
NewFastExercises/TesterTemplate
(16 / 0)
  
1let concatMapSep = https://raw.githubusercontent.com/dhall-lang/dhall-lang/master/Prelude/Text/concatMapSep
2in λ(task : ./NewTaskType) -> ''
3module Main where
4import qualified Exercise
5import Test.QuickCheck
6
7${concatMapSep "\n\n" ./TestKinds ./TestExpr task.tests}
8
9-- The Model solution
10
11${task.model}
12
13-- MAIN --
14main = sequence_ [${concatMapSep "," ./TestKinds
15 ./TestName task.tests} ]
16''
RevProxy.hs
(2 / 2)
  
2222import Numeric.Natural
2323import System.Process.Typed
2424import Network.HTTP.Types
25import qualified Data.Text.Lazy as T
25import qualified Data.Text as T
2626import qualified Data.Text as TS
2727import Data.HashMap.Strict as HM
2828import qualified Data.ByteString as B
7474 print (rawPathInfo request)
7575 case pathInfo request of
7676 [] -> return $ WPRApplication (staticApp (defaultFileServerSettings "."))
77 (fragment:xs) -> case HM.lookup (T.fromStrict fragment) sis of
77 (fragment:xs) -> case HM.lookup (fragment) sis of
7878 Nothing -> return $ WPRApplication (staticApp (defaultFileServerSettings "."))
7979 Just (p,s) -> do
8080 syn $ "Redirecting to "<>TS.unpack fragment<>" at "<> show p<>" / "<>show(dropLeader fragment request)
functional-programming.it.jyu.fi/serviceInfo
(1 / 0)
  
1212 , "ExerciseReturns-webClients"
1313 , "DerivationChecker-service"
1414 , "HEV-service"
15 , "NewHec-service"
1516-- , "CardViewer-service"
1617 , "DrawAST-service"
1718 , "LecturePolls-service"
stack.yaml
(6 / 6)
  
1212 - Cortex
1313 - DrawAST
1414 - ProtectHandlers
15 - Choices/
1516 - Email
1617 - FireJail
1718 - Preludes
2525 - DerivationChecker/DCServiceAPI
2626 - DerivationChecker/DCService
2727 - DerivationChecker/Auxiliaries
28 # - New_Hec/
28 - New_Hec/
2929 - Utils
3030 #- ../TIM-like/MultipleChoicePlugin/
3131 # extra-dep: False
32 # - location:
33 # git: git://yousource.it.jyu.fi/gradu_maankeve/myplugin.git
34 # commit: 5d168015ed24de82266c18d9885a10a05e9199b8
35 # :extra-dep: False
32 - location:
33 git: git://yousource.it.jyu.fi/gradu_maankeve/myplugin.git
34 commit: master
3635 - location: Interpreter/
3736 extra-dep: False
3837 - location: EvaluationResult/
7373 #- "html-entities-1.1.4.2"
7474 #- "skylighting-0.6"
7575 - 'formatting-6.3.4'
76 - 'dhall-1.21.0'
76 - 'dhall-1.22.0'
7777 - simple-logger-0.0.4@sha256:d66b9804a4ec63a2e4b5b284cfec892c5d881050a53947314710eb4b1a1ba91f
7878 - pwstore-fast-2.4.4@sha256:9b6a37510d8b9f37f409a8ab3babac9181afcaaa3fce8ba1c131a7ed3de30698
7979 - template-0.2.0.10@sha256:f822de4d34c45bc84b33a61bc112c15fedee6fa6dc414c62b10456395a868f85