-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPop.hs
More file actions
26 lines (18 loc) · 670 Bytes
/
Pop.hs
File metadata and controls
26 lines (18 loc) · 670 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
module HelVM.HelMA.Common.Collections.Pop where
import Data.Sequence (Seq(..))
class Pop1 e c | c -> e where
pop1 :: c -> (e , c)
instance Show e => Pop1 e [e] where
pop1 (e : c) = (e , c)
pop1 c = error $ "Empty " <> show c
instance Show e => Pop1 e (Seq e) where
pop1 (e :<| c) = (e , c)
pop1 c = error $ "Empty " <> show c
class Pop2 e c | c -> e where
pop2 :: c -> (e , e , c)
instance Show e => Pop2 e [e] where
pop2 (e : e' : c) = (e , e', c)
pop2 c = error $ "Empty " <> show c
instance Show e => Pop2 e (Seq e) where
pop2 (e :<| e' :<| c) = (e , e', c)
pop2 c = error $ "Empty " <> show c