dynamic-pattern-match 1.11 KB
Newer Older
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
-----
unpack :: Dynamic -> Maybe a
unpack (x :: a^)                  = Just x
unpack (f :: A.a: Int -> Maybe a) = Just (f 37)
unpack _                          = Nothing
-----
funcname	unpack
whitespace	 
punctuation	::
whitespace	 
type	Dynamic
whitespace	 
punctuation	->
whitespace	 
type	Maybe
whitespace	 
typevar	a
whitespace	\n
funcname	unpack
whitespace	 
punctuation	(
argument	x
whitespace	 
punctuation	::
whitespace	 
typevar	a
punctuation	^)
whitespace	                  
punctuation	=
whitespace	 
constructor	Just
whitespace	 
argumentinrhs	x
whitespace	\n
funcname	unpack
whitespace	 
punctuation	(
argument	f
whitespace	 
punctuation	::
whitespace	 
existential	A
punctuation	.
typevar	a
punctuation	:
whitespace	 
type	Int
whitespace	 
punctuation	->
whitespace	 
type	Maybe
whitespace	 
typevar	a
punctuation	)
whitespace	 
punctuation	=
whitespace	 
constructor	Just
whitespace	 
punctuation	(
argumentinrhs	f
whitespace	 
literal literal-int literal-int-dec	37
punctuation	)
whitespace	\n
funcname	unpack
whitespace	 
argument	_
whitespace	                          
punctuation	=
whitespace	 
constructor	Nothing