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

Added toggle function to preamble functor #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions src/ConditionalPreamble.fun
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
functor ConditionalPreamble (
structure Grader : GRADER
val show : Grader.Rubric.t -> string option
) =
struct
open Grader

structure Rubric =
struct
open Rubric
val separator = String.implode (List.tabulate (80, fn _ => #"="))
val toString = fn rubric => (
case show rubric of
NONE => ""
| SOME preamble => preamble ^ "\n" ^ separator ^ "\n"
) ^ toString rubric
end
end
16 changes: 4 additions & 12 deletions src/Preamble.fun
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
functor Preamble (
val preamble : string
structure Grader : GRADER
) =
struct
open Grader

structure Rubric =
struct
open Rubric
val separator = String.implode (List.tabulate (80, fn _ => #"="))
val toString = fn rubric =>
preamble ^ "\n" ^ separator ^ "\n" ^ toString rubric
end
end
) = ConditionalPreamble (
structure Grader = Grader
val show : Grader.Rubric.t -> string option = Fn.const (SOME preamble)
)
2 changes: 2 additions & 0 deletions src/sources.cm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Library
functor EquivGraderBucketList
functor EquivGraderList

functor ConditionalPreamble
functor Preamble

structure FormatUtil
Expand Down Expand Up @@ -49,6 +50,7 @@ is
EquivGraderBucket.fun
EquivGrader.fun

ConditionalPreamble.fun
Preamble.fun

FormatUtil.sml