Commit 581b7605 authored by Christopher League's avatar Christopher League
Browse files

Provide assigned expressions for A3, still no submit

parent 550a44c9
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE QuasiQuotes #-}
......@@ -26,6 +27,21 @@ import Hedgehog (Gen)
import Text.Show (showString, showParen, shows)
import Data.Bits
newtype Bit = Bit Bool
deriving (Eq, Enum, Bounded)
instance Show Bit where
showsPrec _ (Bit b) = shows (fromEnum b)
instance Enum (Bit, Bit) where
fromEnum (x,y) = 2 * fromEnum x + fromEnum y
toEnum i = (toEnum (i `div` 2), toEnum (i `mod` 2))
instance Enum (Bit, Bit, Bit) where
fromEnum (x,y,z) = 4 * fromEnum x + fromEnum (y,z)
toEnum i = (toEnum (i `div` 4), y, z)
where (y,z) = toEnum (i `mod` 4)
assn3 :: Activity
assn3 =
makeActivity "a3" 60 "2020-03-01 23:59 EST"
......@@ -51,6 +67,8 @@ handleU2LogicAssnR :: Handler Html
handleU2LogicAssnR = do
uid <- requireAuthId
exprOpt <- runRo $ (^. at uid) <$> loadY A2GivenKey
let bits :: [(Bit,Bit,Bit)]
bits = [minBound..maxBound]
defaultLayout $ do
setTitle "Assignment 2: Boolean logic"
toWidget
......@@ -58,6 +76,9 @@ handleU2LogicAssnR = do
.bigger-text {
font-size: 120%;
}
table.truth td {
text-align: center;
}
|]
[whamlet|
<div .col-12>
......@@ -102,4 +123,23 @@ handleU2LogicAssnR = do
Save your circuit file (it should have the extension
<tt>.circ</tt>) and also upload that below.
<p>
<b>Submit mechanism coming soon…!
|]
-- <table .table .truth>
-- <tr>
-- <th>A
-- <th>B
-- <th>C
-- <th>… other columns …
-- <th>#{fromMaybe "" exprOpt}
-- $forall (a,b,c) <- bits
-- <tr>
-- <td>#{tshow a}
-- <td>#{tshow b}
-- <td>#{tshow c}
-- <td>
-- <td>
-- <input .form-control style="width:3em" type=text size=2>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment