forked from ucsd-progsys/liquidhaskell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLib.hs
More file actions
27 lines (21 loc) · 726 Bytes
/
Lib.hs
File metadata and controls
27 lines (21 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--typeclass" @-}
module Lib where
{-@ data List a = Nil | Cons {lh::a, lt::List a} @-}
data List a = Nil | Cons a (List a)
{-@ reflect foldrList @-}
foldrList :: (a -> b -> b) -> b -> List a -> b
foldrList _ x Nil = x
foldrList f x (Cons y ys) = f y (foldrList f x ys)
{-@ reflect foldlList @-}
foldlList :: (b -> a -> b) -> b -> List a -> b
foldlList _ x Nil = x
foldlList f x (Cons y ys) = foldlList f (f x y) ys
{-@ data NonEmpty a = NonEmpty {neh::a, net:: (List a)} @-}
data NonEmpty a = NonEmpty a (List a)
{-@ reflect head' @-}
head' :: NonEmpty a -> a
head' (NonEmpty a _) = a
{-@ reflect tail' @-}
tail' :: NonEmpty a -> List a
tail' (NonEmpty _ t) = t