Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / queue / list.fun
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7(*-------------------------------------------------------------------*)
8(* ListQueue *)
9(*-------------------------------------------------------------------*)
10
11functor ListQueue(): BASIC_PERSISTENT_QUEUE =
12struct
13
14structure L = List
15
16datatype 'a t = T of 'a List.t
17
18fun destruct(T l) =
19 case L.destruct l of
20 NONE => NONE
21 | SOME(x, l) => SOME(x, T l)
22
23fun empty () = T(L.empty())
24
25fun isEmpty(T l) = L.isEmpty l
26
27fun enque(T l, x) = T(L.append(l, L.single x))
28
29end
30
31structure ListQueue = PersistentQueue(ListQueue())